logoalt Hacker News

Someonetoday at 9:50 AM1 replyview on HN

That’s straight from the standard. https://en.cppreference.com/c/numeric/math/hypot: “if one of the arguments is ±∞, hypot returns +∞ even if the other argument is NaN”

⇒ 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”)


Replies

jjgreentoday at 10:27 AM

Indeed, and makes you realise that NaN is not "not a number" but rather "not a particular number", if one cathetus is infinite then the hypotenuse must be infinite whatever the other cathetus is ...