3 comments

  • aragilar39 minutes ago
    You don't need NaN (or Inf) to have unexpected behaviour with floats and naive loops in lua, using 1e52 is enough. Conflating floating point and integers (independent of encoding) is always a bit of a trap.
  • jjgreen2 hours ago
    <p><pre><code> hypot(Inf, NaN) == Inf </code></pre> made me laugh out loud ...
    • Someone1 hour ago
      That’s straight from the standard. <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;c&#x2F;numeric&#x2F;math&#x2F;hypot" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;c&#x2F;numeric&#x2F;math&#x2F;hypot</a>: <i>“if one of the arguments is ±∞, hypot returns +∞ even if the other argument is NaN”</i><p>⇒ I expect this choice got careful consideration. (Edit: in the end, the reasoning still could have been “unfortunately, existing implementations do it this way; we’ll begrudgingly follow them”)
      • jjgreen38 minutes ago
        Indeed, and makes you realise that NaN is not &quot;not a number&quot; but rather &quot;not a particular number&quot;, if one cathetus is infinite then the hypotenuse must be infinite whatever the other cathetus is ...
  • ColinWright1 hour ago
    See also: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48855045">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48855045</a>