On Apr 5, 11:56 pm, Eugene Goldberg <[email protected]> wrote:

> Python 2.6.5 (r265:79063, Mar 23 2010, 04:49:54)
> >>> 6e-6 % 10e-6
>
> 6.0000000000000002e-06

> Sage Version 4.3.5, Release Date: 2010-03-28
> sage: 6e-6 % 10e-6
> -4.00000000000000e-6
>
> I'm sure sage is wrong.. :(

As William Stein said, Sage is not wrong - it just uses a differed
definition of %. 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

Or use Python floats,

sage: float(6e-6) % float(10e-6)
6.0000000000000002e-06

In both cases the result is a Python float. To make it a Sage's real
number, one can use RR,

sage: RR(_)
6.00000000000000e-6

Alec Mihailovs

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
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.

Reply via email to