Title basically says it all... does GCC support:
long long int
which would be a 64 bit integer?
Also, is long long int
part of the standard? Thanks
Title basically says it all... does GCC support:
long long int
which would be a 64 bit integer?
Also, is long long int
part of the standard? Thanks
long long int
is a part of the C99 standard, and I know GCC supports it. And now I can prove it.
Yes GCC does support long long int
, which is a part of C99 standard.
The standard does not mandate its size in bits, but required values of LLONG_MIN
and LLONG_MAX
in <limits.h>
imply it's at least 64-bit (exact 64-bit wide integer types are int64_t
/uint64_t
from <stdint.h>
).
LLONG_MIN
must be at most -9223372036854775807
LLONG_MAX
must be at least 9223372036854775807
I believe that usually an unsigned long long
is the traditional representation of a 64-bit integer. I'm assuming long long int
would work too, but I've never personally seen any 64-bit vars declared that way before.
On my 32-bit machine,
int main()
{
printf("%d\n", sizeof(long long int));
return 0;
}
compiled with gcc
prints 8 (8 bytes * 8 bits/byte = 64 bits).
Yes, long long
is part of C99, as well as long long
constants (10222333444555LL
) and a few support elements. (LLONG_MAX
, llrint(d)
, llround(d)
, some others.) And gcc has implemented it for some time now.
In order to print long long int variables:
long long int lli = 100000000;
printf("%lld\n", lli);
long longs are well supported, and have been for a long long time [sorry]. As I understand it, this should have been 128 bit on 64-bit platforms, but for compatibility/portability reasons in GCC, has standardised on a 64-bit width.
See also: (u)int128_t, and this discussion on GCC's 128-bit integer support