In article <ma************************************@python.org >,
"W. Vanweersch" <n.**********@hccnet.nl> wrote:
Hello,
The following looks strange to me in Python:
7/-3 gives -3
It looks like Python rounds off -2.33333 to -3! is this correct??
Isn't it -2?
If you like, but not here. (It's really truncation, not rounding.)
It can be unexpected. It keeps this sort of thing working:
(-7 / 3)* 3 + (-7 % 3)
-7
Truncate / toward - infinity. If it truncated toward zero, then you
have to mess with the sign of the result of %, and other odd things
happen.
--John
--
Email to above address discarded by provider's server. Don't bother sending.