__int64 vs long long [solved]

Started by
5 comments, last by intransigent-seal 17 years, 11 months ago
I know that __int64 can only be used on windows, but what about long long? They both make an int of 64 bits, but I'm not sure if there is any difference between the two. Is there? [Edited by - MikeTacular on May 22, 2006 1:56:27 PM]
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Advertisement
__int64 vs long long

"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Quote:Original post by MikeTacular
I know that __int64 can only be used on windows, but what about long long? They both make an int of 64 bits, but I'm not sure if there is any difference between the two. Is there?


__int64 is not platform specific, it is compiler specific - just as long long. While long long is probably making his way into the next C++ standard, none of them are currently standard (both are extensions to the core language). Anyway, there is no real difference between the two: as you said, both are used to create a 64 bit integer... on today's 32 bit platforms. While __int64 is probably guaranteed to always implement 64 bit integers (due to its name), long long is not tied to a particular bit size. It just happen to be 64 bit long on most 32 bit platforms.

I have to recall you what the standard says about the size of different data types: sizeof(char) = 1 byte (the number of bits in the byte is not defined by the standard); then

sizeof(long) >= sizeof(int) >= sizeof(short) >= sizeof(char)

The next standard will probably introduce

sizeof(long long) >= sizeof(long)

The standard don't say anything more, meaning than if sizeof(char) is 8 bits you can build a perfectly compliant compiler where the size of all the other integral type is also 8 bits, the main point beeing that sizeof(int) is not quaranteed to be 32 bits. Which in turn says that when long long will be standardized (if it is), its size will not be guaranteed to be 64 bits.

HTH,
Okay, well that makes sense. Thanks to both of ya.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Quote:Original post by Emmanuel Deloget
The standard don't say anything more, meaning than if sizeof(char) is 8 bits you can build a perfectly compliant compiler where the size of all the other integral type is also 8 bits ...

Actually, I don't think that's exactly true.
I was under the impression that the standard defines certain ranges of values that the types must be able to store, which lead to some guarantees that, eg, the size of the int type must be at least 16 bits. Of course, continuing the same example, sizeof(int) may still be equal to sizeof(char), if the char type is also 16 bits.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
It depends on what standard you're talking about. I believe C99 specifies minimum sizes but older versions don't necessarily. Note that MSVC is not C99 compliant.

If you are using a C99 compiler there are already typedefs for you, e.g. int32_t. Is int64_t standard?
-Mike
Quote:Original post by Anon Mike
It depends on what standard you're talking about. I believe C99 specifies minimum sizes but older versions don't necessarily. Note that MSVC is not C99 compliant.

If you are using a C99 compiler there are already typedefs for you, e.g. int32_t. Is int64_t standard?

Ah, that may well explain it.

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.

This topic is closed to new replies.

Advertisement