Modul (%) in python not like in C?
sjmachin at lexicon.net
Mon Sep 10 00:43:20 CEST 2007
On Sep 10, 8:05 am, Lee Harr <miss... at frontiernet.net> wrote:
> >> Python will always yield a number x = m%n such that 0 <= x < n, but
> >> Turbo C will always yield a number such that if x = m%n -x = -m%n. That
> >> is, since 111 % 10 = 1, -111 % 10 = -1. The two values will always
> >> differ by n (as used above).
> Maybe it is an order-of-operations thing....
> -111 % 10 = -1
> (-111) % 10 = 9
and on the other hand, maybe it's not. Try to think of any language
where unary minus binds so loosely.
More information about the Python-list