I'm trying to understand the rounding function in the floating point notation. Rounding to the nearest interger seems to work according to documentation with x.50 rounding up if x is odd and truncating if x is even. The difficulty I'm having arises when I round to the tenths place with something like -
$rounded=sprintf ("%.1f",$r);
I get the following results:
3.05 is 3.0,
3.15 is 3.1,
3.25 is 3.2,
3.35 is 3.4,
3.45 is 3.5,
3.55 is 3.5,
3.65 is 3.6,
3.75 is 3.8,
3.85 is 3.9,
3.95 is 4.0.
I realize I could write a subroutine to do it correctly, but I really would like to know what's going on. Any ideas?
Thanks