[Haskell-cafe] 9.3 - (2 * 4.5) => 0.3000000000000007

Patrick Mylund Nielsen haskell at patrickmylund.com
Wed Jan 16 14:31:51 CET 2013


This may be of interest if you want full-precision decimals:
http://www.haskell.org/haskellwiki/Libraries_and_tools/Mathematics#Decimal_numbers


On Wed, Jan 16, 2013 at 7:30 AM, Patrick Mylund Nielsen <
haskell at patrickmylund.com> wrote:

> Fun with floating point!
>
> # ghci
> GHCi, version 7.4.2: http://www.haskell.org/ghc/  :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer-gmp ... linking ... done.
> Loading package base ... linking ... done.
> Prelude> 9223372036854775807.0 == 9223372036854775808
> True
>
> http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
>
>
>
> On Wed, Jan 16, 2013 at 7:25 AM, ivan dragolov <ivan at dragolov.net> wrote:
>
>>
>> 9.3 - (2 * 4.5) => 0.3000000000000007
>>
>> I expected 0.3
>>
>> ?
>>
>> --
>> Иван Драголов
>> dragolov.net
>>
>> GSM: 0888 63 19 46
>> GSM за SMS: 0878 82 83 93
>> facebook.com/ivan.dragolov
>> twitter.com/dragolov
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130116/00d9bf79/attachment.htm>


More information about the Haskell-Cafe mailing list