This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Math.abs()  RSS feed

 
Jiji Cherian
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.
This is a question related to Math.abs().
Why Math.abs(Integer.MIN_VALUE)and Math.abs(Long.MIN_VALUE)returns -ve value.
Looking forward for your valuable answers??
Thanks in advance..
 
Joyce Lee
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jiji,

The negation of Integer.MIN_VALUE (-2147483648) will result in overflow since the range for int is -2147483648 to 2147483647. Same for long.

Joyce
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!