[Haskell-cafe] Re: Is logBase right?

Lennart Augustsson lennart at augustsson.net
Sun Aug 23 07:25:14 EDT 2009


You're absolutely right.  It would be easy to change logBase to have
special cases for, say, base 2 and base 10, and call the C library
functions for those.  In fact, I think it's a worth while change,
since it's easy and get's better results for some cases.

  -- Lennart

On Sun, Aug 23, 2009 at 12:41 PM, Steve<stevech1097 at yahoo.com.au> wrote:
> On Sat, 2009-08-22 at 13:03 -0400, haskell-cafe-request at haskell.org
> wrote:
>> Message: 10
>> Date: Sat, 22 Aug 2009 11:24:21 +0200
>> From: Roberto L?pez <plastermoso at hotmail.com>
>> Subject: [Haskell-cafe] Re: Is logBase right?
>> To: haskell-cafe at haskell.org
>> Message-ID: <h6odg8$93j$1 at ger.gmane.org>
>> Content-Type: text/plain; charset="ISO-8859-1"
>>
>> If 4.0 / 2.0 was 1.9999999999999999999998, it would be ok?
>>
>> The real value of log10 1000 is 3 (3.0). It can be represented with
>> accuracy
>> and it should be.
>>
>> You get the accuracy value in Perl, but there is the same problem in
>> Python.
>> It's a bit discouraging.
>>
>
> There is *not* the same problem in Python:
> $ python
> Python 2.6.2 (r262:71600, Jul  9 2009, 23:16:53)
> [GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import math
>>>> math.log10(1000)
> 3.0
>
> Recent work in Python 3 (and Python 2.6) has improved the handling of
> floating point numbers, and addresses exactly the problem that Roberto
> has raised.
>
> I see no reason why Haskell could not improve its handling of floating
> point numbers by using similar techniques.
>
> Steve
>
> _______________________________________________
> 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