"Dotan Cohen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | FIrst of all, how is the % symbol (as in 70%6=4) called in English? | | Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or | the other in error? Is this a known gotcha? I tried to google the | subject however one cannot google the symbol %. Thanks in advance.
Call it a known gotcha inherent to integers. In the realm of counts (aka non-negative integers), there is one sensible definition of division and modulus (remainder). It has various nice properties. With mixed positive and negative integers, there are choices, and none have all the nice properties. The basic problem is that '-infinity' and 0 are in opposite directions instead of the same direction ;-). Guido made one consistent choice (which matches some other languages, I believe). Others have made another consistent choice or no choice at all (leaving the choice to implementations). I believe I have seen at least one book, if not language, that defined // and % so that remainders have the same sign as the numerator. (Or was it denominator?) tjr -- http://mail.python.org/mailman/listinfo/python-list