Re: [Haskell-cafe] Re: Is logBase right?

2009-08-28 Thread Ketil Malde
Lennart Augustsson lenn...@augustsson.net writes: Prelude toRational 697.04157958259998 3065621287177675 % 4398046511104 Prelude toRational 697.0415795826 3065621287177675 % 4398046511104 As you can see, both numbers are represented by the same Double. Haskell prints a Double with the

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-28 Thread Brandon S. Allbery KF8NH
On Aug 28, 2009, at 03:24 , Ketil Malde wrote: What puzzled me (and the parent article indicated), was that Python appeared to be able to work with more precision, and thus be more numerically correct than GHC. Since it's all machine precision floating point, this is even more strange, and I

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-27 Thread Lennart Augustsson
Prelude toRational 697.04157958259998 3065621287177675 % 4398046511104 Prelude toRational 697.0415795826 3065621287177675 % 4398046511104 As you can see, both numbers are represented by the same Double. Haskell prints a Double with the simplest number that converts back to the same bit pattern.

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-25 Thread Henning Thielemann
On Sun, 23 Aug 2009, Lennart Augustsson wrote: 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

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-25 Thread Lennart Augustsson
I don't really care much one way or the other, but since C (math.h) provides functions for base 2 and base 10 with some additional accuracy, I wouldn't mind using them. For a constant base I'd expect the extra comparison to be constant folded, so that's ok. For a non-constant base there would be

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-25 Thread Bryan O'Sullivan
2009/8/22 Roberto López plasterm...@hotmail.com You get the accuracy value in Perl, but there is the same problem in Python. It's a bit discouraging. You don't get an accurate answer with Perl. It just lies to you to keep you happy in your ignorance. $ perl -e 'printf %.22f\n,

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-25 Thread Ketil Malde
Steve stevech1...@yahoo.com.au writes: Also, I had a problem using floating point in Python where round(697.04157958254996, 10) gave 697.04157958259998 Its been fixed in the latest versions of Python: round(697.04157958254996, 10) 697.0415795825 ghci roundN 697.04157958254996 10

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Magnus Therning
2009/8/22 Roberto López plasterm...@hotmail.com: If 4.0 / 2.0 was 1.98, it would be ok? The real value of log10 1000 is 3 (3.0). It can be represented with accuracy and it should be. Well, it already can be, you just need to choose your representation properly: logBase

[Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Steve
On Sat, 2009-08-22 at 13:03 -0400, haskell-cafe-requ...@haskell.org wrote: Message: 10 Date: Sat, 22 Aug 2009 11:24:21 +0200 From: Roberto L?pez plasterm...@hotmail.com Subject: [Haskell-cafe] Re: Is logBase right? To: haskell-cafe@haskell.org Message-ID: h6odg8$93...@ger.gmane.org Content

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Eugene Kirpichov
2009/8/23 Steve stevech1...@yahoo.com.au: On Sat, 2009-08-22 at 13:03 -0400, haskell-cafe-requ...@haskell.org wrote: Message: 10 Date: Sat, 22 Aug 2009 11:24:21 +0200 From: Roberto L?pez plasterm...@hotmail.com Subject: [Haskell-cafe] Re: Is logBase right? To: haskell-cafe@haskell.org

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Lennart Augustsson
at 12:41 PM, Stevestevech1...@yahoo.com.au wrote: On Sat, 2009-08-22 at 13:03 -0400, haskell-cafe-requ...@haskell.org wrote: Message: 10 Date: Sat, 22 Aug 2009 11:24:21 +0200 From: Roberto L?pez plasterm...@hotmail.com Subject: [Haskell-cafe] Re: Is logBase right? To: haskell-cafe@haskell.org

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Felipe Lessa
On Sun, Aug 23, 2009 at 01:25:14PM +0200, Lennart Augustsson wrote: 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

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Steve
On Sun, 2009-08-23 at 15:12 +0400, Eugene Kirpichov wrote: 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

Re[2]: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Bulat Ziganshin
Hello Steve, Sunday, August 23, 2009, 5:27:48 PM, you wrote: ghci roundN 697.04157958254996 10 697.0415795826 afair, double has 13 decimal digits precision, so your 697.04157958254996 represented by another value. you just looking for miracles -- Best regards, Bulat

[Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Steve
On Sun, 2009-08-23 at 17:36 +0400, Bulat Ziganshin wrote: Hello Steve, Sunday, August 23, 2009, 5:27:48 PM, you wrote: ghci roundN 697.04157958254996 10 697.0415795826 afair, double has 13 decimal digits precision, so your 697.04157958254996 represented by another value. you just

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-23 Thread Daniel Fischer
Am Sonntag 23 August 2009 15:27:48 schrieb Steve: On Sun, 2009-08-23 at 15:12 +0400, Eugene Kirpichov wrote: 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,

Re: [Haskell-cafe] Re: Is logBase right?

2009-08-22 Thread Eugene Kirpichov
2009/8/22 Roberto López plasterm...@hotmail.com: If 4.0 / 2.0 was 1.98, it would be ok? I think yes. However, hardware can afford to do computations as accurately as possible, whereas software like Haskell Prelude can't. The real value of log10 1000 is 3 (3.0). It can be