File APIs for Java Developers Manipulate DOC, XLS, PPT, PDF and many others from your application. http://aspose.com/file-tools
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of Head First Android this week in the Android forum!

# Boundary Values

Kanchan K Bulbule
Greenhorn

Joined: Jul 19, 2005
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

Joined: Jul 13, 2004
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

Joined: Sep 02, 2005
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

SCJP <br />SCWCD <br />SCBCD <br />SCEA Preparing
Kanchan K Bulbule
Greenhorn

Joined: Jul 19, 2005
Posts: 20
Thanks all for the gr8 Explanation .

Cheers
Kanchan
Steve Morrow
Ranch Hand

Joined: May 22, 2003
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

Joined: May 22, 2003
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...

Don't get me started about those stupid light bulbs.

subject: Boundary Values