This isn't right, because
print int(28.1+1)
will give 29 too...
If he wants to round greater than .5 to the next unit, the simple thing to do is
print int(28.1+.5)
| [reply] [d/l] [select] |
Rounding != truncation
How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist. Robot Tourist, by Ten Benson
| [reply] |
| [reply] |
It's certainly very easy to understand for you and for me, but it may be not for the one who asked first. So I feel like you really had to explain it after all :)
| [reply] |
ummm, well... er...; unless there's an invisible decimal point I can't see, parents discussing addition of ONE are not responsive.
If one adds 1 (TEN/TENTHS), of course it evals as the next higher number; the example might be more precise if the discussion were about adding ONE/TENTH, 0.1 or adding FIVE/TENTHS (0.5) save for the fact that it just doesn't work that way:
C:\>perl -e "print (28.6)"
28.6
C:\>perl -e "print (28.1)"
28.1
w2k, This is perl, v5.8.6 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail) | [reply] |