posted 21 years ago
ransika, first of all the signatures for the Math.min() methods are:
min(double,double) returns double
min(float,float) returns float
min(long,long) returns long
min(int,int) returns int
And secondly, negative zero is not less that positive zero, as a matter of fact they are both equal.
System.out.println(-0 == 0);
Now when you call Math.min(-0,0) the 4th overloaded method is invoked (the one which return integer), thus outputting positive zero because integer and long values doesn't have an implementation for negative zero (float and double values do implement negative zero however).
Hope this helps.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!