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?
Printable View
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.
> 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.
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.