What is the range of values that can be stored by the short, int, and long integer types in C++?

0333

The range of values for the integer types in C++ is as follows:

  1. short:

    • Range: -32,768 to 32,767 (for signed short)
    • Unsigned short range: 0 to 65,535
  2. int:

    • Range: -2,147,483,648 to 2,147,483,647 (for signed int)
    • Unsigned int range: 0 to 4,294,967,295
  3. long:

    • Range:
      • On 32-bit systems: -2,147,483,648 to 2,147,483,647 (same as int)
      • On 64-bit systems: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (for signed long)
    • Unsigned long range:
      • On 32-bit systems: 0 to 4,294,967,295
      • On 64-bit systems: 0 to 18,446,744,073,709,551,615

These ranges can vary based on the system architecture and whether the types are signed or unsigned.

0 Comments

no data
Be the first to share your comment!