Skip to content

Commit

Permalink
add __round__ to the customized mpmath lib (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera authored and Matthias Köppe committed Jun 22, 2024
1 parent 4c521a1 commit 9f47522
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/sage/libs/mpmath/ext_main.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ cdef class mpf_base(mpnumber):
sage: X().to_fixed(30)
3489660928
"""
return libmp.to_fixed(self._mpf_, prec)
return libmp.to_fixed(self._mpf_, prec)

def __getstate__(self):
return libmp.to_pickable(self._mpf_)
Expand Down Expand Up @@ -2135,6 +2135,9 @@ cdef class mpf(mpf_base):
MPF_sqrt(&r.value, &s.value, global_opts)
return r

def __round__(self, *args):
return round(float(self), *args)

def __richcmp__(self, other, int op):
"""
Compares numbers ::
Expand Down

0 comments on commit 9f47522

Please sign in to comment.