George Russell wrote:
>
> (With hugs as of September 1999)
>
> Prelude> floor 999999999999999999999999999999999999999999999999999999999999.0
> 0
>
> floor maps to Integer, so should have no trouble representing an accurate
> result. I fear that this may be a "feature" in that the Hugs implementors couldn't
> be bothered to write a floor function which actually worked for large numbers.
> If so, returning a completely bogus value is absolutely the worst thing to do.
> It would be much better to fail altogether.
The floor function works fine over large numbers. The problem is
that the large number 9999....999.0 is too large to stored as a Double,
so is stored as Inf.0.
Main> 999999999999999999999999999999999999999.0
Inf.0 :: Double
Now what floor does with Inf is undefined (see page 82 of the H98 report).
The real question is should "floor Inf" return _|_? This is up to the
specific implementation.
BTW, Hugs implemented never "couldn't be bother to write .... which actually worked for
...".
They have limited resources and limited time, and strongly encourage feedback and bug
reports. We do our best to produce quality products with our limited resources.
Andy Gill