[Pyrex] Mod operator in python and pyrex
Robert Kern
robert.kern at gmail.com
Fri May 18 19:41:37 UTC 2007
stephen at theboulets.net wrote:
> I am getting this message in a pyrex module:
>
> "Invalid operand types for '%' (float; double)"
>
> The line of code is:
>
> "rotorthetanow = rotortheta %(2.*pi)"
>
> All three variables are floats.
>
> Does the mod operator work in python for floats but not in pyrex?
Correct. % doesn't work for floats in C, so when Pyrex is told to do % on cdef
float or double variables, it raises an error.
> Any
> workaround? Thanks.
cdef extern from "math.h":
double fmod(double x, double y)
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Pyrex
mailing list