from c++ - Definition of int64_t - Stack Overflow
a) Can you explain to me the difference between int64_t and long (long int)? In my understanding, both are 64 bit integers. Is there any reason to choose one over the other?
The former is a signed integer type with exactly 64 bits. The latter is a signed integer type with at least 32 bits.
b) I tried to look up the definition of int64_t on the web, without much success. Is there an authoritative source I need to consult for such questions?
http://cppreference.com covers this here: Fixed width integer types (since C++11) - cppreference.com. The authoritative source, however, is the C++ standard (this particular bit can be found in §18.4 Integer types [cstdint]).
c) For code using int64_t to compile, I am including
, which doesn't make much sense to me. Are there other includes that provide a declaration of int64_t?
It is declared in
from Fixed width integer types (since C++11) - cppreference.com
| int8_t int16_t int32_t int64_t | signed integer type with width of exactly 8, 16, 32 and 64 bits respectively with no padding bits and using 2's complement for negative values (provided if and only if the implementation directly supports the type) (typedef) |
the exactness/imutable length can be very handy when dealing directly with HW.
from c++ - ULL suffix on a numeric literal - Stack Overflow
From the gcc manual:
ISO C99 supports data types for integers that are at least 64 bits wide ( . . . ) . To make an integer constant of type long long int, add the suffix LL to the integer. To make an integer constant of type unsigned long long int, add the suffix ULL to the integer.
These suffixes have also been added to C++ in C++11, and were already supported long long (pun intended) before that as compiler extensions.
==> all suffix specify the least amount of bits assigned, no truncation will be forced if we declare say:
0xffff ffff ffff ffffUL



