aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abs( ) method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abs( ) method" Watch "abs( ) method" New topic
Author

abs( ) method

k j goban
Greenhorn

Joined: Feb 01, 2001
Posts: 1
what will be the o/p for the following and why
pls give me the explanation.
class Test
{
public static void main(String[] args)
{
System.out.println(Math.abs(Integer.MIN_VALUE));
}
}
thanks
with rgds
Anshuman Acharya
Ranch Hand

Joined: Jan 19, 2001
Posts: 144
Integer.MIN_VALUE = -2147483648
Integer.MAX_VALUE = 2147483647
hence the abs of min-value is out of the range of the int primitive, ansd since they run about in a circle, the o/p goes rigth to the lowest value after crossing the highest one. i.e we effectively get Integer.MIN_VALUE BACK !
Balu Ramachandran
Greenhorn

Joined: Oct 16, 2000
Posts: 16
hi,
Answewr is : -2147483648
abs() returns absolute value of the given argument.
but hear min. value for Integer wrapper exceeds. it is a cyclic process so that only u got above answer.
------------------
R.Balu


R.Balu
 
wood burning stoves
 
subject: abs( ) method