Skip to content

Commit 900fbc5

Browse files
committed
Replace division by zero with +-inf
1 parent 1b3f398 commit 900fbc5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/sage/rings/integer.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7755,9 +7755,9 @@ cdef double mpz_get_d_nearest(mpz_t x) except? -648555075988944.5:
77557755
# Check for overflow
77567756
if sx > 1024:
77577757
if resultsign < 0:
7758-
return -1.0/0.0
7758+
return float('-inf')
77597759
else:
7760-
return 1.0/0.0
7760+
return float('inf')
77617761

77627762
# General case
77637763

src/sage/rings/rational.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3993,9 +3993,9 @@ cdef double mpq_get_d_nearest(mpq_t x) except? -648555075988944.5:
39933993
return 0.0
39943994
elif shift >= 971: # |d| > 2^1024
39953995
if resultsign < 0:
3996-
return -1.0/0.0
3996+
return float('-inf')
39973997
else:
3998-
return 1.0/0.0
3998+
return float('inf')
39993999

40004000
sig_on()
40014001

0 commit comments

Comments
 (0)