C++ Integer Modifiers

integers – we can store both positive and negative numbers.

by default, the type is signed.

signed and unsigned int types

here, n is the number of bits for a type in memory.

unsigned int – only stores positive numbers.

unsigned int – represents up to 4 billion.

 

Storing negative value in unsigned int type may give compiler error.

short and long

combination of types we can have with integers.

  • short – takes 2 bytes of memory.
  • long – takes either 4 or 8 bytes of memory.
  • long long – takes 8 bytes of memory.

NOTE – these modifiers only apply to integer types; those which can store decimal numbers.