This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes MAX_VALUE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "MAX_VALUE" Watch "MAX_VALUE" New topic
Author

MAX_VALUE

suresh kamsa
Ranch Hand

Joined: Jul 30, 2001
Posts: 149
public static void main (String[] args) {
int i1 = (Integer.MAX_VALUE + 2);
int i2 = (Integer.MIN_VALUE + 1);
int i3 = (Integer.MIN_VALUE + 2);
int i4 = (Integer.MIN_VALUE + 3);
System.out.println((i1==i2)+","+(i1 ==i3)+","+(i1 ==i4));
}
Prints output as : true,false,false
Can one expalin with binary representation of the output. Is it possible to represent MAX_VALUE in binary? If so how. Thanks again.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Integer values go in a circle -- if you add 1 to MAX_VALUE (a large positive number), you will get MIN_VALUE (a large negative number).
MAX_VALUE is represented in binary as
0111 1111 1111 1111 1111 1111 1111 1111
If you add 1 to that, you get MIN_VALUE
1000 0000 0000 0000 0000 0000 0000 0000


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MAX_VALUE
 
Similar Threads
Small doubt in Boxing & == & equals()
Wrappers question
Bit addition's
Interger.MAX_VALUE?
MAX_VALUE