There are three different integer data types:
- Short Integer – 2bytes
- Long Integer – 4bytes
- Long Long Integer – 8bytes
Note : Size of data types depends upon OS.
In Turbo C, size of an integer is 2byte. Similarly, in Linux OS (GCC Compiler) it is 4bytes.
To check the size of integer, type file a.out.
vi /usr/include/limits.h >To check limits of data type.
There are two categories for data types:
- Signed (1st bit will be reserved for sign or unsigned).
Signed Integer: -32768 to 32767
Unsigned Integer: 0 to 65535
“%hd” is a format specifier of the short integer.
“%d” is for Integer/Long Integer.
If the system is 32bit wide than we can store up to 4GB of data.
Endianess: The way of storing a data in giving memory Location is called Endianess.
It is of two different types:
- Little Endian.
- Big Endian.
Intel processor and controllers follows Little Endian. Whereas Motorola supports Big Endian.
Little Endian: LSB is Stored in a given Lowest Memory.
In above Example, you can get an Idea how data will be stored in giving Lowest Memory.
Big Endian: LSB is stored in given Highest Memory.
%d – Signed Integer Decimal.
%o – Octal number representation.
%x – Hexadecimal number representation.
%u – Unsigned Integer decimal.