[Shootout-list] floating point rounding

Daniel South WildCard_25@HotMail.Com
Thu, 31 Mar 2005 19:01:02 +1000


James McIlree wrote:
| 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.
|
Actually, that's a round to even. If you use 0.011 -> 0.019, you should 
find that 0.015 rounds to 0.02 for Java and Lisp.
Java defaults to round to even, to round up you'll have to use something 
like "import java.math.BigDecimal" and configure it.

Daniel South