sorry Himanshu, i didn't understand what you were trying to tell
1.4E-45 -1.4E-45 -2147483648 -2147483648 -1 1 integer max value: 2147483647
Output completed (0 sec consumed)
i got the following output...
why is n being assigned a -ve value where we assigned -m to n
Abhi vijay
Ranch Hand
Joined: Sep 16, 2008
Posts: 509
posted
0
Hi, check compiling this code.
I think it will clear your doubt. The Range of byte is -128 - 127. So it cannot hold a value -b1 which is +128.
saipavan vallabhaneni
Ranch Hand
Joined: Nov 14, 2008
Posts: 34
posted
0
thanks himanshu and abhi
i understood now
Ruben Soto
Ranch Hand
Joined: Dec 16, 2008
Posts: 1032
posted
0
The min value of any integer type is represented at the bit level by the fist bit (the sign bit) being one, and the rest of the bits being 0. This means that:
The same is obviously not the case of MAX_VALUE and -MAX_VALUE, since the bit patterns capable of representing negative integers is one more than those capable of representing strictly positive integers.
0111...11 // MAX VALUE 1000...00 // MAX VALUE 1's complement 1000...01 // MAX_VALUE 2's complement
In this case, negating MAX_VALUE will give you what you would expect from a mathematical point of view.
All code in my posts, unless a source is explicitly mentioned, is my own.