Thursday 6 October 2011

Data Types

If you consider your daily life then just imagine that in daily life you have different type of data around you e.g. names , roll no. , cell no. , email id , percentage , GP etc.You have seen that their are different type of data we have to remember or we have to calculate.In every language their are certain data types on which we perform certain calculations or tasks and every data type has certain limitations and we cannot exceed it.

Certain data types are floating point , integer , char , Boolean.A chart is shown here which will show you the ranges of them according to their platform.


It is better for you to know about  Signed and Unsigned.Now two questions arises..??
  • What is Signed ?
  • What is Unsigned ?

Signed
 Signed is basically by default variables e.g. whenever we initialize a variable (int x) it is by default signed i.e. that it contain both positive numbers and negative numbers in its range/limit.In case of integer type range will be i.e. -32768 to 32767.

Unsigned is basically when we don’t need negative numbers in our scenario or condition and only want positive numbers then we use unsigned with our initialization e.g. ( unsigned int x ; ) and range of int when it is unsigned will be 65534  i.e. 2*32767..This keyword "unsigned" before the initialization of any data type.


Tip : If you'll use this type in your codes then it can prevent your code from distortion.Best example of unsigned is unsigned long and it can store 0 to 4 billion.

No comments:

Post a Comment