The range of a long is –2,147,483,648 to 2,147,483,647 and is 4 bytes. An integer is system dependant and can be equal to or shorter than the size of a long. I suppose under some circumstances they could be the same, except a long will give more predictable results when being placed on different computers.
for 32bit compillers is no range difference. But type are different. By default if you do a
x = 1234;
the 1234 is considered as int. When you overload operator = to long and do an = with a 1234 you will get compiller error if you don't have an operator = (int...).
long could be 64bit in the future, that's why the keyword "long" exist. It is for forward compatibility. Maybe size of long will not change in the future, but maybe yes.
IEEE standard is 32 bits, some computing groups in Japan refuse to conform to IEEE standard. Also, on CRAY supercomputers a word is 64 bits. It is possible that in the forseeable future, home computing may advance to 64bits per word.
> By standard, long is always 32-bits!
C99 states that a long should be at LEAST 32 bits, it is not limited to be exactly 32 bits.
Since C++ has <climits> (which is called limits.h in C), I would say that C++ follows the same rules for determining the limits on the ranges of data types.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.