4 ms·
Why is NaN even a concept in modern languages? We don’t have a special “not a string” that all string functions return when they have no useful value to return
by ken 7y ago
Why is NaN even a concept in modern languages? We don’t have a special “not a string” that all string functions return when they have no useful value to return.
- saagarjha 7y agoBecause it's part of IEEE 754.
- ken 7y agoSo? There’s lots of old standards that don’t fit well with modern programming languages, so we abandoned them, or only use the parts that still make sense.
- saagarjha 7y agoIEEE 754 is one of the standards like two's complement arithmetic which are widely used and have a number of clear advantages, so we continue to use them.
- mac01021 7y agoBecause what is the CPU supposed to do if you divide zero by zero or take the square root of -1? It's actually not exactly a decision being made by the language designers. The IEEE standard governs the floating point logic embedded in ALU hardware. Programming languages tend to expose floating point math in its rawest form for performance reasons.