4 ms·
Ruby defines division by zero for Floats 1.0 / 0 => Float::INFINITY and 0 * Float::INFINITY => Float::NAN I think infinity is a more intuitive resul
by ushi 8y ago
Ruby defines division by zero for Floats
1.0 / 0
=> Float::INFINITY
and
0 * Float::INFINITY
=> Float::NAN
I think infinity is a more intuitive result, but most of the time i get this as a user i would rather see 0 (bought books per month: Infinity). As a programmer i like to get an error, because i forgot to handle an edge case...
- scarejunba 8y agoThat's IEEE 754 https://en.wikipedia.org/wiki/IEEE_754#Exception_handling https://en.wikipedia.org/wiki/IEEE_754#Exception_handling
- nostalgeek 8y agoAFAIK Javascript does this as well.