the value range between int and long are both the same (-2147483648 to 2147483647) and they are both 4 bytes big! whats the difference and when do i know which variable type to use between the two when it comes to making my own app's?
the value range between int and long are both the same (-2147483648 to 2147483647) and they are both 4 bytes big! whats the difference and when do i know which variable type to use between the two when it comes to making my own app's?
A long integer has to be bigger than or equal to an int, so, if you want to set aside more memory for a variable, i would use long.
Last edited by beene; 01-02-2007 at 09:01 AM.
> the value range between int and long are both the same
On your machine, with your current compiler, for today.
The standard specifies minimum ranges for data types. Use that to guide what you should choose.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
An int is defined as at least 16 bits long. It may be longer -- typically if you use a 16 bit compiler, int is 16 bits, 32 bit compiler = 32 bits, 64 bit compiler = 64 bits, but I do not believe that this is guaranteed. Still, on every compiler I've seen, sizeof(int) == sizeof(void *).
A long is defined as at least 32 bits long, again it may be longer.
You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.