Signed long int
(Created page with "{{FormatInfo | name = signed long int | formattype = electronic | subcat = Data types | subcat2 = C++ data types | subcat3 = | subcat4 ...") |
(released) |
||
Line 16: | Line 16: | ||
| uniform type = | | uniform type = | ||
| conforms to = | | conforms to = | ||
− | | released = | + | | released = 1983 |
| image = | | image = | ||
| caption = | | caption = |
Latest revision as of 07:04, 13 May 2015
C++ signed long int will take at least 32 bits of memory to hold and cannot be less than signed int in any implementation; it can, however, differ from compiler to compiler. Signed long usually gets stored as two's complement integer, but it is not a requirement of the standard.
It can be shortened during declaration or conversion to long.
long can safely store values -2³¹ – 2³¹-1, if the value gets too large or too small, a roll over can take place. While the fact of a roll over is a guarantee at some point, a coder cannot assume that it will happen in a specific place, LONG_MIN and LONG_MAX constants from <climits> library can be used to determine that.
For most purposes when a "large number" is needed, people use long, it is also the largest built-in integer type that was available before C++11.
[edit] Other C++ data types of the same size
- unsigned long int
- char32_t (although this is not a requirement, and the program should not rely on these two being the same size, unless you know that you will not change the compiler used).
- signed int (depends upon your implementation)
[edit] Other C++ data types storing signed integers
- signed char at least 8 bits
- short at least 16 bits, not smaller than signed char
- int not less than 16 bits, not smaller than short
- long long not less than 64 bits, not smaller than long