[Shootout-list] floating point rounding
Simon Geard
simon@whiteowl.co.uk
Thu, 31 Mar 2005 14:19:36 +0100
Bengt Kleberg wrote:
> 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
>
>
> Erlang:
>
> 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
>
>
> bengt
fortran90 does round to even:
[simon@localhost simon]$ ./rounding
0.00100 -> 0.00
0.00200 -> 0.00
0.00300 -> 0.00
0.00400 -> 0.00
0.00500 -> 0.01
0.00600 -> 0.01
0.00700 -> 0.01
0.00800 -> 0.01
0.00900 -> 0.01
[simon@localhost simon]$ ./rounding
0.12500 -> 0.12
0.25000 -> 0.25
0.37500 -> 0.38
0.50000 -> 0.50
0.62500 -> 0.62
0.75000 -> 0.75
0.87500 -> 0.88
1.00000 -> 1.00
1.12500 -> 1.12
Simon Geard