Sean Russell <ser / germane-software.com> wrote:
> Dossy wrote:

>> Float allowing division by zero is certainly not of least surprise
>> to me.  ;-)

> Yeah, I think it is sort of silly, too.  From what I remember of my math, 
> dividing by zero is "illegal".

> However, IEEE 754 (Institute of Electrical and Electronics Engineers. IEEE 
> Standard for Binary Floating-Point Arithmetic. ANSI/IEEE Std 754-1985.) 
> defines rules for operations such as this, and it specifies that n/0 -> 
> Infinity, -n/0 -> -Infinity, and 0/0 -> NaN.  Because of this, I'm a little 
> surprised that Integer math in Ruby doesn't follow the same rules.

Well, simplifying a little you could say that integer::0 == 0, but float::0
is a number in the general region of 0 (no strict equality test on floats),
so that n/0.0 = some unboundedly large value. The IEEE standards don't
apply to integer arithmetic, as other people have pointed out; the computer
concept of 'floating point arithmetic' is an approximation to, but not
identical to the mathematical concept of 'real arithmetic'.

Note that this is not a question of tying Ruby to the underlying C
implementation; it is merely a recognition of the fact that floating point
arithmetic needs a different set of rules.

-- 
Martin DeMello