Problems using modulo

Diez B. Roggisch deetsNOSPAM at web.de
Tue Apr 20 08:20:38 EDT 2004


Gonzalo Sainz-Trápaga (GomoX) wrote:

> On Mon, 19 Apr 2004 17:51:53 +0200, Diez B. Roggisch wrote:
>> AFAIK modulo is mathematically only properly defined on
>> integers - so you should stick to them.
> 
> Modulo is fine for any number (even irrational ones). For example,
> acos(sqrt(3)/2) is congruent to pi/6 mod 2*pi. Technically, two numbers
> are congruent mod n when the rest of the division by n is the same, it
> doesn't matter whether n is an integer or not.

Hum - usually, division in fields like Q or R doesn't yield a rest, doesn't
it? Thats what I meant. Of course if you define division as 

a / b := subtract b from a until a is < b

and count the iterations, you can have modulo. So I stand corrected that the
modulo op in python then makes sense (even if numerical problems arise, but
thats a different topic).


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list