I'm seeking for a macro representing the maximum value of uint64_t
as UINT_MAX
is for unsigned int
. i.e. I need this value to guaranteed to be (1<<64)-1.
I tried to use UINT64_MAX
, but compiling with g++ results in:
'UINT64_MAX' was not declared in this scope
It's worth to mention that I have this line #define __STDC_LIMIT_MACROS
in the code before using UINT64_MAX
.
I was surprised to not find helpful information around the web about it.
The UInt64 value type represents unsigned integers with values ranging from 0 to 184,467,440,737,095,551,615. UInt64 provides methods to compare instances of this type, convert the value of an instance to its string representation, and convert the string representation of a number to an instance of this type.
long: The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).
Using the cstdint
header portably can be quite a challenge (it is missing from some MSVC implementations). At the same time numeric_limits::max()
can be hard to use without constexpr
and it is not actually required to work with uint64_t
. If you don't care about those things too much, std::numeric_limits<uint64_t>::max()
will most likely do the trick.
Boost.Integer has an implementation of cstdint
and comes with an extra traits class to get a constant maximal value. A compliant implementation of cstdint
should also provide the macro UINT64_MAX
, but I'm not sure about boost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With