Integer math question
Derek Ledbetter
derekledbetter at mindspring.com
Sun Jan 4 06:02:41 EST 2004
On Sat, 3 Jan 2004 8:32:07 -0800, Frank wrote
(in message <3987e01c.0401030832.114c6f2a at posting.google.com>):
> In C++
>
> i = 5 / 10 and
> i = -5 / 10 both have the same result 0.
Actually this is implementation defined in C89 and standard C++. Either
-5/10 == 0 and -5%10 == -5, as in your implementation, or -5/10 == -1
and -5%10 == 5, like Python. In C99, and possibly a future version of
C++, it's always done the first way (rounding towards zero).
--
Derek Ledbetter
derekl at serve.com
Heavy boots of lead
fills his victims full of dread
Running as fast as they can
Iron Man lives again!
More information about the Python-list
mailing list