From 900fbc50057a916c71c9f7622bcbb840e758f8b7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 28 Oct 2024 21:44:24 +0800 Subject: [PATCH] Replace division by zero with +-inf --- src/sage/rings/integer.pyx | 4 ++-- src/sage/rings/rational.pyx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 9616e7946bc..291cbb786d7 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()