[Haskell-cafe] Little errors in number calculations

Abby Henríquez Tejera paradoja at gmail.com
Tue Nov 17 09:29:03 EST 2009


It's curious that Hugs "lies"...

Thanks for the answers :) .

2009/11/15 Lennart Augustsson <lennart at augustsson.net>:
> Hugs is wrong, as you can easily see by evaluating
>   let x = 123.35503 * 10.0 in x == read (show x)
> With ghc it comes out as True and with Hugs as False.
>
>  -- Lennart
>
> On Sat, Nov 14, 2009 at 9:00 PM, Abby Henríquez Tejera
> <paradoja at gmail.com> wrote:
>> Hi.
>>
>> I've seen that in GHC sometimes there are little errors in some basic
>> number calculations:
>>
>> *Prelude> 123.35503 * 10.0
>> 1233.5502999999999
>>
>> *Prelude> properFraction 123.35503
>> (123,0.3550299999999993)
>>
>> whereas in Hugs no such errors seem to occur (that I have found, at
>> least):
>>
>> *Hugs> 123.35503 * 10.0
>> 1233.5503
>>
>> (but:)
>>
>> *Hugs> properFraction 123.35503
>> (123,0.355029999999999)
>>
>> I understand that error may (and will) happen in floating point, but
>> it surprises me that they do so easily, and, above all, the difference
>> between GHC and Hugs. Does someone know why does this difference
>> occur?
>>
>> (Thanks in advance, by the way :) ).
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>


More information about the Haskell-Cafe mailing list