[Haskell-cafe] Is logBase right?

Jeff Heard jefferson.r.heard at gmail.com
Tue Aug 25 10:29:47 EDT 2009


I always thought that he who compares floating point numbers for
equality was acting in tangent of reason...

-- Jeff

On Sat, Aug 22, 2009 at 4:02 AM, Mark Wotton<mwotton at gmail.com> wrote:
> he who compares floating point numbers for equality is in a state of sin.
>
> mark
>
> On 22/08/2009, at 5:00 AM, Roberto wrote:
>
>> Hi,
>>
>> There is a mistake is logBase:
>>
>> $ ghci
>> GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
>> Loading package ghc-prim ... linking ... done.
>> Loading package integer ... linking ... done.
>> Loading package base ... linking ... done.
>> Prelude> logBase 10 10
>> 1.0
>> Prelude> logBase 10 100
>> 2.0
>> Prelude> logBase 10 1000
>> 2.9999999999999996                  <--- eeeerrgghhhh!
>> Prelude> logBase 10 10000
>> 4.0
>>
>>
>> My host is a Debian GNU/Linux 5.0.2 (lenny) with the following GHC
>> packages:
>>
>> ii  ghc6                                 6.10.4-1
>> ii  ghc6-doc                             6.10.4-1
>> ii  libghc6-mtl-dev                      1.1.0.2-7+b1
>> ii  libghc6-utf8-string-dev              0.3.5-1+b1
>> ii  libghc6-x11-dev                      1.4.5-6
>> rc  libghc6-x11-doc                      1.4.2-1
>> ii  libghc6-x11-xft-dev                  0.3-3+b3
>> ii  libghc6-xmonad-contrib-dev           0.8.1-3+b3
>> rc  libghc6-xmonad-contrib-doc           0.8-2
>> ii  libghc6-xmonad-dev                   0.8.1-5
>>
>> Regards!
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> _______________________________________________
> 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