longs

Started by
8 comments, last by SiCrane 19 years, 5 months ago
The gospel according to St. MSDN says that the long type is 32bits wide and is synonymous with int on 32bit platforms. What does this imply for 64bit hardware? The way it is worded suggests that long is widened but int is not. Is this correct?
- CheeseMonger
Advertisement
I guess it means that if the code is compiled with a 32bit compiler int will be tyhe same as long, and if compiler with a 64bit compiler int will be the same as __int64.
I suppose it doesn't depend on the hardware, because once the code is compiled, the sizeof types will not change.
I'n no expert in this area, so I can be wrong...
int is typically the size of a system word, so on a 64 bit system, int would be 64 bits.

After that this says sizeofs are: char <= short <= int <= long

So, if int is 64 bits, long must be atleast 64 bits too.
AMD64/GCC 3.4. chars are 8 bits (as you would expect).

sizeof(char) ≡ 1
sizeof(short) == 2
sizeof(int) == 4
sizeof(long) == 8
sizeof(float) == 4
sizeof(double) == 8
sizeof(long double) == 16

For any integral type T, sizeof(T) ≡ sizeof(signed T) ≡ sizeof(unsigned T)
Quote:Original post by Miserable
sizeof(long double) == 16


O_O I don't believe that; AFAIK there's no IEEE standard for 128-bit floating point types, just 80-bit. Or did I miss something? :s
Quote:Original post by Zahlman
Quote:Original post by Miserable
sizeof(long double) == 16


O_O I don't believe that; AFAIK there's no IEEE standard for 128-bit floating point types, just 80-bit. Or did I miss something? :s


Googlefu turned up this: http://www.x86-64.org/lists/discuss/msg00022.html.

It implies (if I read correctly) the existance of a 128 bit floating IEEE standard, as well as the use of 16 bytes wheither or not the format used is 80 or 128 bit.
Quote:Original post by Zahlman
Quote:Original post by Miserable
sizeof(long double) == 16


O_O I don't believe that; AFAIK there's no IEEE standard for 128-bit floating point types, just 80-bit. Or did I miss something? :s

Go ahead and get yourself an AMD64, install GCC 3.4, and see for yourself. [grin]

I can't tell you about IEEE standards, but that's what it's like on my computer ...
Quote:Original post by Zahlman
Quote:Original post by Miserable
sizeof(long double) == 16


O_O I don't believe that; AFAIK there's no IEEE standard for 128-bit floating point types, just 80-bit. Or did I miss something? :s


IEEE 754r, the current working name for the revision of IEEE 754-1985, has 128 bit floats in the pipeline. Last time I checked, IEEE 754r was timelined for completion in December 2005.
Quote:Original post by SiCrane
Last time I checked, IEEE 754r was timelined for completion in December 2005.


Do standards committees make it a habit to tell people things that they've known for several years, or is it just bad luck?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
If I understand what you're asking, in most international standards organizations, draft versions of the standards usually exist for about a year or more before actually becoming official. Usually not much gets changed in that time period, but implementations are created and issues with the specification are brought up before the standards committee and addressed. For example, ambiguities in the language are discovered and clarified. Or exciting things if a word should be "should" instead of "shall".

This topic is closed to new replies.

Advertisement