Skip to main content
GameDev.net gamedev.net
🔒 Locked

long =int?

Started by derek7 Apr 21, 2005 at 7:22 PM 7 replies 1.3k views
Original Post
derek7
derek7
in my pc long =int =4byte it is true in other compute?
nmi
nmi
Int is usually assumed to be the word size on a platform. For 16 bit systems an int is 16 bits and for 32 bit systems an int is 32 bits. For 64 bit systems this holds no longer, here int usually is 32 bits too.

http://www.opengroup.org/public/tech/aspen/lp64_wp.htm
Kwizatz
Kwizatz
It is probably true in all 32bit computers, in a 16 bit computer (286 Intel CPU and less) sizeof(int) = 2, sizeof(long)=4, in a 64bit CPU int is probably 8, long would be 4 (though I am not sure).

This doesnt make sence, but you have to remember that when long was named long, CPU's were 16 bit at the most.
JohnBolton
JohnBolton
Quote:
Original post by Kwizatz
It is probably true in all 32bit computers, ...


... except PS2 (depending on the compiler, of course).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Vanke
Vanke
It depends on operating system, and cpu, and compiler, it can be different among different computers that why you should never assume the size of any data type.
smart_idiot
smart_idiot
It's pretty much up to your compiler, and it's decision can vary depending on the target system/cpu.

All your can be sure of is that short is at least as big as char, int is at least as big as short, and long is at least as big as int.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
Rayno
Rayno
Quote:
Original post by Kwizatz
in a 64bit CPU int is probably 8, long would be 4 (though I am not sure).

I've only used one 64bit OS, but it was vice-versa (sizeof(long)=8, sizeof(int)=4).
bobstevens
bobstevens
Here is the one thing you can rely on:

sizeof (int) <= sizeof (long)

It wouldn't suck for you to make specific defines to use for 8, 16, 32, 64 bit types. Then when you run into a platform where they're not what you think, all you have to do is typedef them correctly rather than single-stepping through your code trying to figure out why everything broke all of the sudden.
darookie
darookie
Quote:
Original post by bobstevens
Here is the one thing you can rely on:

sizeof (int) <= sizeof (long)


Sorry. The ISO standard only states sizeof(long) >= 4.
Ints on some 64bit systems are 8 bytes big, while longs are 4 bytes in size.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.