Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Math.abs()method

 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI guys

here is my code


I thought the answers 2 and 3 are correct as Integer.MIN_VALUE is eqaul to Integer.MAX_VALUe+1.
As Math.abs(Integer.MIN_VALUE) returns Integer.MIN_VALUE.
But the answer given is 2.

Thanks in advance
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that answer 3 is meant to imply an integer (not bit) representation that is one more than Integer.MAX_VALUE without overflow. In other words, a large positive value beyond the range of an int.

(Answer 2 is correct.)
[ September 08, 2005: Message edited by: marc weber ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic