in reply to Re^2: Decimal numbers calculations done inconsistently: Odd behavior!
in thread Decimal numbers calculations done inconsistently: Odd behavior!
Round up if the previous digit is odd and round down if it is even.$ perl -e 'my $c = 0.5; $c +=1 and printf "%f -> %0.0f\n", $c, $c for +1..10;' 1.500000 -> 2 2.500000 -> 2 3.500000 -> 4 4.500000 -> 4 5.500000 -> 6 6.500000 -> 6 7.500000 -> 8 8.500000 -> 8 9.500000 -> 10 10.500000 -> 10
|
|---|