negative integer division

Dan Bishop danb_83 at yahoo.com
Tue Feb 8 22:34:46 EST 2005


Mark Jackson wrote:
> Imbaud Pierre <pierre.imbaud at wanadoo.fr> writes:
> > integer division and modulo gives different results in c and
python,
> > when negative numbers
> > are involved. take gdb as a widely available c interpreter
> >   print -2 /3
> > 0 for c, -1 for python.
> > more amazing, modulos of negative number give negative values! (in
c).
> > from an algebraic point of view, python seems right, but I thought
> > python conformity to the underlying c compiler was a strong
commitment,
>
> AIUI the C standard is silent on the issue, and hence the C behavior
is
> implementation-dependent.

The *original* C standard is silent on the issue, but the current
standard requires the wrong behavior.




More information about the Python-list mailing list