[Haskell-cafe] Re: Is logBase right?
Ketil Malde
ketil at malde.org
Tue Aug 25 13:11:18 EDT 2009
Steve <stevech1097 at 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
> 697.0415795826
Is there something special with this number?
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 697.04157958259998
697.04157958259998
>>> 12345.678901234567890
12345.678901234567
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> 697.04157958259998
697.0415795826
Prelude> 12345.678901234567890
12345.678901234567
So, Python manages to keep more decimals than GHC for your number, but
for other numbers, the precision appears to be the same.
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list