|
|
|
|
|
by jameshart
1568 days ago
|
|
This article conflates the representational limits of floating point with the concept of NaN in a way that I suspect will lead to more confusion, not less. Zero/zero doesn’t return NaN because it isn’t representable within floating point - it returns NaN because it is an expression that has no mathematical meaning. The fact that sqrt(-1) has two valid nonreal answers has nothing to do with why it returns NaN - after all, sqrt(4) has two valid real answers so is also technically not representable by a single floating point value, but that doesn’t typically result in NaN. NaN is just an error value you get when you ask floating point math a dumb question it can’t usefully answer. Far more interesting and subtle are the ways in which positive and negative infinity and positive and negative zero let you actually still obtain useful (at least for purposes of things like comparison) results to certain calculations even if they overflow the representable range. |
|