C integer Data Type



Integer Data Type : About Short Integer & Long Integer

  1. Integers are whole numbers with a wide range of values that are machine dependent.
  2. Integer occupies 2 bytes memory space and its value range limited to -32768 to +32767

How this range is Calculated ?

Size of Integer =  2  bytes
No of Bits      =  16 bits  
                =  MSB bit is considered as Sign Bit
                   (Skip that bit)
                =  16 bits - 1 bit
                =  15 bits

Maximum Range of Integer

Max Range       =  2 Raise to 15
                =  32768

Minimum Range of Integer

Min Range       =  2 Raise to -15
                =  -32768

Types of Integer Data Types :

  1. Integer
  2. Short Integer
  3. Long Integer

Some Important Points :

  • Range of Integer is [2^-15 to 2^+15]
  • Each type is again classified into signed and unsigned integer.
  • Unsigned integer don’t have sign bit , so its range is 0 to 65535
  • A short int requires half the amount of storage than normal integer.
  • Unlike signed integer, unsigned integers are always positive and use all the bits for the magnitude of the number. Therefore the range of an unsigned integer will be from 0 to 65535.
  • The long integers are used to declare a longer range of values and it occupies 4 bytes of storage space.

Syntax of Declaring Integer

int num1;
short int num2;
long int num3;

Example of Integer Data types

  • 500
  • 6764
  • 32100
  • 32766