2007 Jul 20 8:11 AM
data : a1 type i .
now howmany values can i hold it seems it can hold 4 bytes .
1 byte = 8 bits
1bit = 1 / 0
so 8 bits = 8 * 1 = 8 (abcdefgh)
so 4 bytes = 4 * 8 = 32 bits.
it means a1 can hold 9999999999999999999999999999999
please explain if it is not true.
2007 Jul 20 8:15 AM
Hi ..
Data type I (Integer) can hold max 10 digit numbers.
Here 4 bytes does not mean you can store upto 32 digits value.
but the calcuation is like
for 1 byte it can store max 2 power 8 values = 256
like that 4 bytes means maximum 2 power 32 .
beyond that limit raises an ARITHMETIC_OVERFLOW exception.
Hope this gives the idea.
<b>Reward for helpful solutions.</b>
2007 Jul 20 9:37 AM
1 byte = 8 bits
1bit = 1 / 0
so 8 bits = 8 * 1 = 8 (abcdefgh)
so 4 bytes = 4 * 8 = 32 bits.
in this 32 bits one bit is reserved for sign ( + or -) now in the remaining 31 bits you can use for storing the value i.e is maximum 2^31 - 1 = 2147483647( i.e. yuou can put 1 or 0 for any bit and by binary to decimal conversion it comes 2147483647).
generally the range is from -2147483648 to 2147483647 for an integer.
regards
shiba dutta