diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 206c4c458d8..ffc5ee16e0f 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -7755,9 +7755,9 @@ cdef double mpz_get_d_nearest(mpz_t x) except? -648555075988944.5: # Check for overflow if sx > 1024: if resultsign < 0: - return -1.0/0.0 + return float('-inf') else: - return 1.0/0.0 + return float('inf') # General case diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index 272650abeef..bc29e952b1a 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -3993,9 +3993,9 @@ cdef double mpq_get_d_nearest(mpq_t x) except? -648555075988944.5: return 0.0 elif shift >= 971: # |d| > 2^1024 if resultsign < 0: - return -1.0/0.0 + return float('-inf') else: - return 1.0/0.0 + return float('inf') sig_on()