signed long int

From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name signed long int
Released 1983

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.

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)

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
Personal tools