Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

real numbers don't support __mod__ #5132

Closed
burcin opened this issue Jan 30, 2009 · 3 comments
Closed

real numbers don't support __mod__ #5132

burcin opened this issue Jan 30, 2009 · 3 comments

Comments

@burcin
Copy link

burcin commented Jan 30, 2009

sage: 10.0 % 2r
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/burcin/.sage/temp/karr/24765/_home_burcin__sage_init_sage_0.py in <module>()
----> 1 
      2 
      3 
      4 
      5 

TypeError: unsupported operand type(s) for %: 'sage.rings.real_mpfr.RealLiteral' and 'int'

A quick look through sage/rings/real_mpfr.pyx reveals that there is no __mod__ method defined.

MPFR documentation here:

http://www.mpfr.org/mpfr-current/mpfr.html#Integer-Related-Functions

suggests that one of mpfr_fmod() or mpfr_remainder() should be used, depending on the desired rounding properties. Since I live blissfully in the exact arithmetic world, I have no idea which one is more suitable for Sage.

Nevertheless, a patch that uses mpfr_remainder() is attached.

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/5132

@burcin burcin added this to the sage-3.3 milestone Jan 30, 2009
@zimmermann6
Copy link

comment:1

Attachment: trac_5132-mpfr_mod.patch.gz

This is a duplicate of #825.

@mwhansen
Copy link
Contributor

mwhansen commented Feb 2, 2009

comment:2

Looks good to me. This also fixes the broken example reported at #825.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Feb 2, 2009

comment:3

Merged in Sage 3.3.alpha4.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Feb 2, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants