Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
24630: address reviewer's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed Mar 19, 2018
1 parent dc476b0 commit 2796d1a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,8 @@ cdef class RealField_class(sage.rings.ring.Field):
sage: R(complex(1.7))
1.7000
"""
from sage.structure.element import parent
if hasattr(x, '_mpfr_'):
return x._mpfr_(self)
if isinstance(x, complex) and x.imag == 0:
x = x.real
cdef RealNumber z
z = self._new()
z._set(x, base)
Expand Down Expand Up @@ -1480,6 +1477,8 @@ cdef class RealNumber(sage.structure.element.RingElement):
mpfr_set_si(self.value, x, parent.rnd)
elif isinstance(x, float):
mpfr_set_d(self.value, x, parent.rnd)
elif isinstance(x, complex) and x.imag == 0:
mpfr_set_d(self.value, x.real, parent.rnd)
elif isinstance(x, RealDoubleElement):
mpfr_set_d(self.value, (<RealDoubleElement>x)._value, parent.rnd)
elif HAVE_GMPY2 and type(x) is gmpy2.mpfr:
Expand Down

0 comments on commit 2796d1a

Please sign in to comment.