Range of int and long datatypes
I found out that the range is int and long on 32 bit windows:
signed int: -32767 to 32767
signed long: -2147483647 to 2147483647
why does int have the same range as long as msdn says? http://msdn.microsoft.com/en-us/library/s3f49ktz%28VS.80%29.aspx
+2
a source to share
5 answers
When working with binary representations of integers, you can calculate the maximum range of signed data types based on the number of bits used to represent the data using the formula:
low value: -2 ^ (N-1) highest value: 2 ^ (N-1) - 1
where N is the number of bits.
For one reason or another, the "signed int" type you are talking about is represented by 16 bits, and the "signed long" is represented by 32 bits.
Also note that the ranges you posted appear to be incomplete, note that the 16 bit signed int range goes to -32768 which is lower than your range.
0
a source to share