why there are so many data types and why limitation of range
y so many datatypes?
it is required to define the kind of data u r storing in memory. requried bcoz wen u want to perform some kind of operartion on tat data (eg. addtion or division) u shld knw if tat memory location has integer data or a character data or anythgn else. bcoz if u gonna perform divison on characters the output wuld make no sense and undesired too.
y limitation of range?
lets discuss this a bit.
the memory is divied into bits. once we decide tat we need to define types of data being stored, next we should define hw mch(max) of memory will each type of data shall occupy. this is required bcoz one shld knw before storing data that sufficient memmory is available. if we knw the required amt of memory , we can compare with the available memory n find out if sufficient free memory is available or not. next issue is the range. we decide on maximum range rather than minimum. we decide to give limited amount of memory(bits) for each type of data(datatype). the number of bits will decide the maximum range of value it can store(every data is converted into binary bits n then stored in memory). for example for datatype 'long' we give 8 bytes. but if the numbers tat we normally store say ranges between -30000 to +30000 half of the bits will be wasted. thus we create a smaller range n call it 'int'. tats how float and double were decided. 'char' is given a fixed and small memory space 1byte per character.