<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 11/1/2024 12:11 PM, Eirik Bjørsnøs
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CA+pBWhsBx5_h0mfu_Q8ZMf35L6hQyvcHseYc-c38h7ra_ZtSSA@mail.gmail.com">
      
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>Just an observation from a floating point layman:</div>
        <div><br>
        </div>
        <div>I noticed that Float and Double uses "It is equal to the
          value.." when describing various constant values
          like MIN_VALUE, MAX_VALUE etc.</div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>A few releases back, a discussion of "quality, equivalence, and
      comparison of floating-point values" was added to
      java.lang.Double:<br>
    </p>
    <p><a class="moz-txt-link-freetext" href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Double.html#equivalenceRelation">https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Double.html#equivalenceRelation</a></p>
    <p>That note discusses the topics in question.<br>
    </p>
    <blockquote type="cite" cite="mid:CA+pBWhsBx5_h0mfu_Q8ZMf35L6hQyvcHseYc-c38h7ra_ZtSSA@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>However, Float.NaN and Double.NaN instead uses "equivalent
          to":</div>
        <div><br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace">/**<br>
          </font><font face="monospace"> * A constant holding a
            Not-a-Number (NaN) value of type<br>
          </font><font face="monospace"> * {@code float}.  It is <i>equivalent</i>
            to the value returned by<br>
          </font><font face="monospace"> * {@code
            Float.intBitsToFloat(0x7fc00000)}.<br>
          </font><font face="monospace"> */<br>
          </font><font face="monospace">public static final float NaN =
            0.0f / 0.0f;</font></blockquote>
        <div><br>
        </div>
        <div>Is this difference in terms deliberate and justified by
          there being more than one NaN bit pattern? Is the
          implementation allowed to return any NaN, since all NaNs
          are equivalent, even when not equal?</div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>In terms of NaN, relevant factors are there are multiple bit
      patterns than encode a NaN and a NaN is not equal to itself per
      the IEEE 754 standard.</p>
    <p>HTH; cheers,</p>
    <p>-Joe<br>
    </p>
  </body>
</html>