Skip to content

Commit 91dc079

Browse files
Additional fmpz to float conversion tests
1 parent 9382a42 commit 91dc079

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/flint/test/test_all.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ def test_fmpz():
207207
assert math.ceil(f) == 2
208208
assert type(math.ceil(f)) is flint.fmpz
209209

210+
# Float conversion should follow Python rounding conventions
211+
for mant in range(2**56 - 64, 2**56 + 64):
212+
for shift in range(0, 900, 20):
213+
for eps in range(-5, 5):
214+
f = (mant << shift) + eps
215+
assert float(f) == float(flint.fmpz(f))
216+
assert float(-f) == float(flint.fmpz(-f))
210217
# Test float conversion overflow
211218
assert raises(lambda: float(flint.fmpz(2**1024)), OverflowError)
212219
assert raises(lambda: float(flint.fmpz(-2**1024)), OverflowError)

0 commit comments

Comments
 (0)