Comment by ok_computer
2 days ago
Because representing infinity is not possible outside of symbolic logic and isn’t encodable in floats. I think it is a simple numerical reason and not a deeper computer reason.
2 days ago
Because representing infinity is not possible outside of symbolic logic and isn’t encodable in floats. I think it is a simple numerical reason and not a deeper computer reason.
Well, infinity is totally representable with IEEE 754 floats. For example 1.0/0.0 == +inf, -1.0/0.0 == -inf, but 0.0/0.0 == NaN.
A smart compiler should be able to figure out a better value for 0/0, depending on context.
For example:
In this case it should probably print +inf when i == 0.
But:
Now it is not clear, but at least we know it's an infinity so perhaps we need a special value +-inf.
And:
In this case, the value for 0/0 can be 1.
Well, it could, but that would be against the spec. The hardware implements IEEE 754, most languages guarantee IEEE 754, and transforming code so that 0.0/0.0 doesn't result in NaN would be invalid.
I'm incorrect. there's a spec discussed here
https://www.gnu.org/software/libc/manual/html_node/Infinity-...