[Shootout-list] floating point rounding

James McIlree ovrskeek@mac.com
Thu, 31 Mar 2005 00:04:27 -0800


	I ran some quick tests with what I had available, I admit
its not great coverage :-).

	It looks like C, Ruby, and Python round up at .5, Java and
Lisp round up at .6. It would be interesting to see what some of
the other languages choose to do.

Java:

0.0010 0.00
0.0020 0.00
0.0030 0.00
0.0040 0.00
0.0050 0.00
0.0060 0.01
0.0070 0.01
0.0080 0.01
0.0090 0.01

Lisp:

0.001 0.00
0.002 0.00
0.003 0.00
0.004 0.00
0.005 0.00
0.006 0.01
0.007 0.01
0.008 0.01
0.009 0.01

C:

0.001000 0.00
0.002000 0.00
0.003000 0.00
0.004000 0.00
0.005000 0.01
0.006000 0.01
0.007000 0.01
0.008000 0.01
0.009000 0.01

Ruby:

0.001000 0.00
0.002000 0.00
0.003000 0.00
0.004000 0.00
0.005000 0.01
0.006000 0.01
0.007000 0.01
0.008000 0.01
0.009000 0.01

Python:

0.001000 0.00
0.002000 0.00
0.003000 0.00
0.004000 0.00
0.005000 0.01
0.006000 0.01
0.007000 0.01
0.008000 0.01
0.009000 0.01