RFR: JDK-8294539: Augment discussion of equivalence relations on floating-point values [v2]

Joe Darcy darcy at openjdk.org
Tue Oct 4 19:31:57 UTC 2022


On Tue, 4 Oct 2022 05:50:26 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/Double.java line 181:
>> 
>>> 179:  * <li> {@code +0.0} and {@code -0.0} are distinguished from each other.
>>> 180:  * <li> every bit pattern encoding a NaN is considered equivalent to each other
>>> 181:  * <li> an infinite value is equivalent to an infinite value of the same sign
>> 
>> Seems like this line on infinities could be reworded. I wouldn't quibble over this except that I had to read it several times to figure out what it meant. The statement on NaN is universally quantified, whereas the statement on infinite values starts off sounding like an existential quantifier. Possibly: "all infinite values of the same sign are considered equivalent to each other."
>
> Update as suggested and added some cross-links in from BigDecimal; thanks.

PS To further spell things out, I added an additional trailing paragraph:

"For two binary floating-point values a and b, if neither of a and b is zero or NaN, then the three relations numerical equality, bit-wise equivalence, and representation equivalence of a and b have the same true/false value. In other words, for binary floating-point values, the three relations only differ if at least one argument is zero or NaN."

-------------

PR: https://git.openjdk.org/jdk/pull/10498


More information about the core-libs-dev mailing list