Q: Feature Wish: "%" Extension

Tim Peters tim.one at home.com
Mon Nov 5 04:15:35 CET 2001

[Jive Dadson]
> I work in robotics.  Our robots have several rotary axes, each of which
> can turn considerably more than 360 degrees.  The positions 5 degrees
> and 365 degress are not equivalent, because the arms can contain wires
> and tubes that can only be twisted so many times.  I am continually
> using the following function, often to "mod out" multiples of 360
> degrees.
> // "Floating point modulus" function
> inline double fpMod(double x, double modulus) {
>     return  x-floor(x/modulus)*modulus;
> }

Why do you use that instead of the platform fmod() function?  Is it
important that the result be non-negative in this application?

More information about the Python-list mailing list