Followup

From the javadoc comments in Math.java: “If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.”

Let me just point out that Java thinks that NaN (Not a Number), positive zero, negative zero, or either positive or negative infinity are different values, and this is not a quirk of Java. The language thinks this because the standard for computer representation of real numbers thinks this; the language is just exposing the constructs so that programmers can handle these different values.

At least nowadays positive zero will test as equal to negative zero. (That wasn’t always true, you know.)

Published by pirateguillermo

I play the bagpipes. I program computers. I support my family in their various endeavors, and I enjoy my wonderful life.

Leave a ReplyCancel reply