We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3fe9723 commit d79ff6eCopy full SHA for d79ff6e
src/flint/types/fmpz.pyx
@@ -106,6 +106,10 @@ cdef class fmpz(flint_scalar):
106
return fmpz_get_intlong(self.val)
107
108
def __float__(self):
109
+ if fmpz_bits(self.val) <= 1023:
110
+ # Known to be representable by a IEEE-754 double
111
+ return fmpz_get_d(self.val)
112
+
113
cdef slong exp
114
# fmpz_get_d_2exp is always accurate
115
# math.ldexp handles overflow checks
0 commit comments