• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

simple programming question.

Not open for further replies.
well your question is not clear ...

data types are there to help you manage your data ... after all you cant store every information in one kind of storage ... categorization is the basic step of management.

limitation of range .. hmm... the variables that you create are stored in RAM .. now this is a finite resource .. you won't want one variable to occupy your entire memory, would you?
so there is a size of every variable .. the amount of bytes a variable can occupy... this helps efficient usage of memory.

was your question an attempt of sarcasm towards the existing programming languages or was it an authentic query?


Broken In
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.
Not open for further replies.
Top Bottom