HELP: restore my faith in Python
Grant Edwards
grant at nowhere.
Mon Mar 6 18:17:45 EST 2000
In article <m38zzw9gcd.fsf at greebo.nodomain.de>, Bernhard Herzog wrote:
>grant at nowhere. (Grant Edwards) writes:
>
>> If you want to round to the nearest integer, then use
>> int(x+0.5). That's been idiomatic in programming for longer
>> than I've been around.
>
>Unfortunately, it might produce incorrect results for negative x, at
>least on some systems which truncate towards 0 and towards -infinity:
Yup.
Back it the good days of VAX Fortran, you would use the SIGN
function to transfer the sign of x so that negative numbers
worked they way they should:
int(x + sign(x)*0.5)
But we digress...
--
Grant Edwards grante Yow! Are the STEWED PRUNES
at still in the HAIR DRYER?
visi.com
More information about the Python-list
mailing list