Infinity (?!)

In article,


Dossy wrote:

On 2002.05.30, Paul Brannan wrote:

On Thu, May 30, 2002 at 10:05:24PM +0900, Dossy wrote:

Float allowing division by zero is certainly not of least surprise
to me. :wink:

A Float is implemented by a C double. A Fixnum is a C long. In C, a
long can be only a number, but a double has many special values
(particularly NaN, inifinity, and positive/negative zero).

For Ruby to work any other way would surprise me.

Considering that Ruby is an OO language, the fact that the
implementation is so tightly coupled to the underlying architecture
surprises me.

Just as true, false and nil are instances of TrueClass, FalseClass
and NilClass, I would have assumed infinity to be an instance of
Number, along with NaN being an instance of Number as well.
Or, something like that.

Infinity and NaN are part of the IEEE floating point number
standard. It’s not just a C thing, but the standard behaviour
for floating point numbers on a computer. There is no similar
standard for integers.

    • Booker C. Bense