Search This Blog

Sunday, February 1, 2009

Variable Datatypes & Range in C

Variable Types:
There are a number of ‘built-in’ data types in C. These are listed below. Where a
shorter version of the type name exists, this is given in brackets; essentially the base
type int is implicit whenever short , long, or unsigned are used.
  1. short int (short)
  2. unsigned short int (unsigned short )
  3. char
  4. unsigned char
  5. signed char
  6. int
  7. unsigned int (unsigned )
  8. long int (long)
  9. unsigned long int (unsigned long )
  10. float
  11. double
  12. long double
The range of values that can be stored in variables of these types will depend on the
compiler and computer that you are using, but on an IBM PCs and the Borland Turbo
C compiler the ranges are:
  • short int -128 ® 127 (1 byte)
  • unsigned short int 0 ® 255 (1 byte)
  • char 0 ® 255 or -128 ® +127 2 (1 byte)
  • unsigned char 0 ® 255 (1 byte)
  • signed char -128 ® 127 (1 byte)
  • int -32,768 ® +32,767 (2 bytes)
  • unsigned int 0 ® +65,535 (2 bytes)
  • long int -2,147,483,648 ® +2,147,483,647 (4 bytes)
  • unsigned long int 0 ® 4,294,967,295 (4 bytes)
  • float single precision floating point (4 bytes)
  • double double precision floating point (8 bytes)
  • long doubl e extended precision floating point (10 bytes)

No comments: