6 How to Calculate the range of Data Types?

If you want to represent any data in machine level we required two electronic pluses ON and OFF. We represent this pluses with the help of 0 and 1.

0 = OFF
1=ON

and a bit is a small memory location to hold electronic pulse i.e to hold either 0 or 1 and technically we called a bit as memory location.

1 byte = 8 bit's

ex:  byte b=100;
In this example byte is a datatype
                          b is a variable name which is initialized with the value 100.

byte = 8 bits
So 2 8 is 256 values that means we can store 256 values.

But Whenever we are talking about values then we need to consider both positive as well as negative value.

So we divide 256/2 = 128.
So totally we have -128 to +128 digits.
So Now  0 is also a value therefore -128 to 0 to +127
-2 7 to 0 to 27 -1 .

So the range is  -2 8-1 to 0 to 28-1 -1
.


And this same process for another data types example int takes 4 byte .
So the range will be  -2 32-1 to 0 to 232-1 -1.



Previous
Next Post »