3 ms·
Ruby seems to handle this correctly: >> 1 / -0.0 => -Infinity Although you have to put the 0.0, otherwise it treats it as an integer and makes it 0.
by d3nj4l 6y ago
Ruby seems to handle this correctly:
>> 1 / -0.0
=> -Infinity
Although you have to put the 0.0, otherwise it treats it as an integer and makes it 0.
- darig 6y agoShouldn't the answer be NaN or an illegal division by 0 fatal error/exception?
- fortran77 6y agoDividing by zero is "undefined" not "Infinity" because there is not a "well defined limit." https://en.wikipedia.org/wiki/Division_by_zero https://en.wikipedia.org/wiki/Division_by_zero
- d3nj4l 6y agoFrom the article you link: > Depending on the programming environment and the type of number (e.g. floating point, integer) being divided by zero, it may generate positive or negative infinity by the IEEE 754 floating point standard.