On Tuesday, November 24, 2015 at 7:39:53 AM UTC-8, steven roumajon wrote:
>
> Hi,
>
> For obscure reasons, I tried modulo with floats with sage.
> I had an unexpected result.
>
> In sage:
> sage: 0.257%0.5
> -0.243000000000000
>
> Tried under python:
> >>> 0.257%0.5
> 0.257
>

The sage behaviour follows  mpfr_remainder (which it uses); see 
http://www.mpfr.org/mpfr-current/mpfr.html#Integer-Related-Functions . It 
looks like the Python floats (which don't use mpfr) use something 
corresponding to mpfr_fmod.

The behaviour is properly documented (although perhaps relatively difficult 
to find). Try

sage: a=1.0
sage: a.__mod__?

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to