Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is C++11's long long really at least 64 bits?

People also ask

Is long long a 64-bit?

long long - target type will have width of at least 64 bits.

Is unsigned long long 64-bit?

unsigned long long is the same as unsigned long long int . Its size is platform-dependent, but guaranteed by the C standard (ISO C99) to be at least 64 bits.


The C++ standard references the C standard for this, see [c.limits]. LLONG_MAX is defined in <climits> with the same meaning as C's <limits.h>'s LLONG_MAX. And this is what C has to say:

5.2.4.2.1 Sizes of integer types <limits.h>

The values given below shall be replaced by constant expressions suitable for use in #if preprocessing directives. [...] Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign.

[...]

-- maximum value for an object of type long long int

LLONG_MAX +9223372036854775807 // 263 -1

A signed type that must be capable of representing the value 9223372036854775807 requires 64 bits or more.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!