On Apr 6, 2010, at 12:17 AM, Paul Zimmermann wrote:
If one wants to have the same answer as Python does (always
nonnegative),
then function math.fmod can be used. For example,
sage: from math import fmod
sage: fmod(6e-6,10e-6)
6.0000000000000002e-06
first Python does not always give a nonnegative result:
(6e-6) % (-10e-6)
-4.0000000000000007e-06
secondly this does not match the math.fmod function either:
sage: from math import fmod
sage: fmod(6e-6,-10e-6)
6.0000000000000002e-06
I would recommend that Sage "%" follows one of the C99 standard
functions,
fmod or remainder. Maybe fmod would be better, and remainder could
be provided
as a different method.
I would rather agree with integers here
sage: -1 % 10
9
(Personally, I think C got % wrong, or at least the easy to implement
choice won over the more useful, as x%n gives different results for
various x in the same residue class mod n.)
- Robert
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
To unsubscribe, reply using "remove me" as the subject.