Problems using modulo

Griff griffph at aol.com
Mon Apr 19 13:45:07 EDT 2004


Mike,

Thanks for this. I haven't used %r before, in fact it doesn't even
seem to be mentioned in my "Python Essential Reference" book so I
probably wouldn't have come across it for ages.

I've since tried to run a similar piece of code on my 'C' compiler and
pretty quickly discovered/remembered that C doesn't allow you to do
modulo operations on floats full stop ... so I regard whatever Python
gives us as a bonus!

The quickest workaround I've found is to do 
( round(t,5) % round(interval,5)) which seems to give the results I
need.

cheers

- Griff



More information about the Python-list mailing list