This week's giveaway is in the Spring forum.We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!See this thread for details.

# Boundary Values

Kanchan K Bulbule
Greenhorn
Posts: 20
I was wondering why
-----------------------------------------
Integer.MIN_VALUE -1 = Integer.MAX_VALUE
Integer.MAX_VALUE + 1 =Integer.MIN_VALUE
-----------------------------------------
and the same is true for Long !!!
But not for Double and Float may be they represent floating point numbers.

Any clue...?

Cheers
Kanchan

Priya Jothi
Ranch Hand
Posts: 168
It is because once it(int or long) exceed its range it starts to wrap over the opposite range of values.

Abhishek Jain
Greenhorn
Posts: 26
i would like to add more

2S representaiton for Number type
=================================
E.G.
taking 8 bit number and it can be extended for 32 bit integer

max 8 bit no=01111111=127
01111111
+00000001
-------------
10000000

now hows 10000000 treated by compiler
compiler after seeing one as left most bit would assure no is -ive
and would convert that value using 2s complemnt

01111111 one 's complement
now add 1 to it this would be the value
ie
10000000 128 but with -ive sign

hence Max8bitno+1=Min8bitNo

got it.........

but this kind of representation is not there for float and double
they are having seperate rep for mantisaa and exponent so they dont work
in this way

Regards
Abhishek

Kanchan K Bulbule
Greenhorn
Posts: 20
Thanks all for the gr8 Explanation .

Cheers
Kanchan

Steve Morrow
Ranch Hand
Posts: 657
Thanks all for the gr8 Explanation .

Please make the extra effort to write out words such as "great". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership.

http://faq.javaranch.com/view?UseRealWords

Steve Morrow
Ranch Hand
Posts: 657
Along those lines, someone pointed out that he'd read that as "gracht". This led me to the somewhat amusing "grocho". Then I remembered my Italian lessons and "grotto", which actually *does* carry a genuine meaning in English as well.

Then, I just got silly.
http://www.travlang.org/wordofday/110.html

At least in Esperanto, I can grok what he was talking about...