tags:

views:

2040

answers:

7

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

+7  A: 

long long int is a part of the C99 standard, and I know GCC supports it. And now I can prove it.

Chris Lutz
+16  A: 

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>).

  1. LLONG_MIN must be at most -9223372036854775807
  2. LLONG_MAX must be at least 9223372036854775807
Alex B
Just to add.. In windows its equivalent would be _int64
Aviator
Actually, to be strict, it is the equivalent of int64_t from <stdint.h> (which is C99 too).
Alex B
I never know this header! Thanks!
Aviator
+2  A: 

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.

Marc W
`long long int` is just a signed 64-bit (or more) integer. Nothing particularly unusual about it.
bdonlan
+5  A: 

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).

Mark Rushakoff
`size_t` format strings should use `"%zu"` not `"%d"` (likewise, `ssize_t` must use `"%zd"`). This is a problem on 64-bit platforms, where size_t is often a 64-bit type, while int can still be 32-bit.
bdonlan
+4  A: 

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.

DigitalRoss
+3  A: 

In order to print long long int variables:

long long int lli = 100000000;

printf("%lld\n", lli);
eyalm
+1  A: 

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

Lee B
"this should have been 128 bit on 64-bit platforms": care to support this affirmation in any way?
FX
I did say, "as I understand it". I can support the idea only in that, as wikipedia says, "The term word is used for a small group of bits which are handled simultaneously by processors of a particular architecture. The size of a word is thus CPU-specific." So logically, a long long word would be longer on an wider arch. However, from the same wikipedia page, the de facto standard does seem to be that long long is 64-bit.http://en.wikipedia.org/wiki/Integer_%28computer_science%29
Lee B