Haskell: 9.3 - (2 * 4.5) => 0.3000000000000007
?
6 Replies
@dragolov:
I expected 0.3
?
Welcome to IEEE 754 double-precision floating point arithmetic. http://en.wikipedia.org/wiki/IEEEfloatingpoint
Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 9.3 - (2 * 4.5)
0.30000000000000071
$ irb -v
irb 0.9.5(05/04/13)
$ irb
irb(main):001:0> 9.3 - (2 * 4.5)
=> 0.300000000000001
$ perl -v
This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi
...
$ perl -e "print 9.3 - (2 * 4.5);"
0.300000000000001
$ bc -v
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
$ echo 'scale=100; 9.3 - (2 * 4.5)' | bc
.3
James