Actually, round to even would be correct for numbers ending in .5
This is new to me, up to now I always rounded .5 up. But you seem to be right, e.g. Mathematica rounds in that way. The reason for this is that the rounding should not give a statistical bias - as far as I understand it.
But in this case, 1.025 really is closer to 1.02 printf "%.20f => %.2f\n", 1.025, 1.025;
D'oh, well, been tripped up again by floating point number representations (tye explains that very nicely here in this thread) ...# this prints 1.02499999999999990000 => 1.02
What is interesting is the following example where the rounding towards the nearest even number (0) does not take place - and the 0.5 can be represented exactly as a float (as merlyn pointed out somewhere else in this node):
printf "%.20f => %.0f", 0.5, 0.5; # prints 0.50000000000000000000 => 1
-- Hofmator
In reply to Re4: Filthy Floats
by Hofmator
in thread Filthy Floats
by THuG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |