wood burning stoves
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Math.min() and Math.max() 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 "Math.min() and Math.max()" Watch "Math.min() and Math.max()" New topic

Math.min() and Math.max()

Meg Adal
Ranch Hand

Joined: Mar 12, 2002
Posts: 70
I have following code

The output was

I saw the API which says that

public static double min(double a,
double b)
this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other is negative zero, the result is negative zero.

Why there is -ve zero for double but not for integer
Thanks in advance
[ August 15, 2002: Message edited by: Megan Adal ]
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The representation of doubles (and floats) is: sign bit, exponent, mantissa. Negative zero differs from positive zero only in the sign bit.
The representation of integers is "two's-complement", which has only one zero.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
I agree. Here's the link: http://aspose.com/file-tools
subject: Math.min() and Math.max()
It's not a secret anymore!