Integer Data – Type

There are three different integer data types:

  1. Short Integer – 2bytes
  2. Long Integer – 4bytes
  3. 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:

  1. Signed (1st bit will be reserved for sign or unsigned).
  2. Unsigned.

Range :

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:

  1. Little Endian.
  2. Big Endian.

Intel processor and controllers follows Little Endian. Whereas Motorola supports Big Endian.

Little Endian:  LSB is Stored in a given Lowest Memory.

Untitled Diagram (6).jpg

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.

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: