Guillaume Marcais
4/5/2005 3:11:00 AM
Le 4 avr. 05, à 16:14, Daniel Berger a écrit :
>> It seems to me that the the relevant part in the text is:
>>
>> "If x is NaN, a NaN shall be returned."
>>
>> So the *nix implementation is correct and the Windows one is not.
>
> I think it's open for debate. It causes a ZeroDivision error on both
> Perl and Python if we want to look at what other languages do.
Well, I should have said: "it behaves according to what the quoted
article specifies".
Looking at the Ruby code, Ruby relies on the the OS implementation of
the mathematic library. So here it is not Ruby that generate the error
or Nan in the first, but the OS. So Windows and *nix disagree
apparently on the behavior.
So the question is: should Ruby rely on the system for its mathematical
computation, or should it provide an abstraction layer to offer a
consistent behavior across platforms?
> Yeah, I wasn't thinking. It would be kinda neat if we could (though I
> have no idea how that would be implemented).
>
> What about a compromise where an error is raised, and "NaN" is included
> in part of the error message, e.g.
>
> Errno::EDOM: NaN (sqrt)
>
> Or something like that?
Sure, sounds good. But I am not in the right person to make that
decision though.
Guillaume.