I want to use 64 bit integers in my C++ code. I understand I can either #include <cstdint>
and then declare a uint64_t
or use unsigned long long
(or the equivalent for signed versions).
However, it appears that support for this was not added until C++11
and I would like my code to be compatible with compilers that don't have full C++11 support.
What is a good portable way to support 64 bit integers in C++?
uint64_t
,uint32_t
, etc or specificallyuint64_t
? – Wendall__builtin_clzll
give the same answer whether you uselong long
(at least 64 bits) orint64_t
(exactly 64 bits)? – Santiagosantillan__builtin_clzll(value) + 64 - CHAR_BIT * sizeof(unsigned long long)
if you should manage to encounter a platform withlong long
wider than 64-bits. – Radman