guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 40/69: positive?, negative? use integer lib


From: Andy Wingo
Subject: [Guile-commits] 40/69: positive?, negative? use integer lib
Date: Fri, 7 Jan 2022 08:27:12 -0500 (EST)

wingo pushed a commit to branch wip-inline-digits
in repository guile.

commit fd9b412edc7cd57e56ec1c4226fd00b88be5fe7c
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Tue Jan 4 13:59:46 2022 +0100

    positive?, negative? use integer lib
    
    * libguile/numbers.c (scm_positive_p, scm_negative_p): Use integer lib.
---
 libguile/numbers.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libguile/numbers.c b/libguile/numbers.c
index 6aa944111..54d2f0a51 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -4974,11 +4974,7 @@ SCM_PRIMITIVE_GENERIC (scm_positive_p, "positive?", 1, 
0, 0,
   if (SCM_I_INUMP (x))
     return scm_from_bool (SCM_I_INUM (x) > 0);
   else if (SCM_BIGP (x))
-    {
-      int sgn = mpz_sgn (SCM_I_BIG_MPZ (x));
-      scm_remember_upto_here_1 (x);
-      return scm_from_bool (sgn > 0);
-    }
+    return scm_from_bool (scm_is_integer_positive_z (scm_bignum (x)));
   else if (SCM_REALP (x))
     return scm_from_bool(SCM_REAL_VALUE (x) > 0.0);
   else if (SCM_FRACTIONP (x))
@@ -4998,11 +4994,7 @@ SCM_PRIMITIVE_GENERIC (scm_negative_p, "negative?", 1, 
0, 0,
   if (SCM_I_INUMP (x))
     return scm_from_bool (SCM_I_INUM (x) < 0);
   else if (SCM_BIGP (x))
-    {
-      int sgn = mpz_sgn (SCM_I_BIG_MPZ (x));
-      scm_remember_upto_here_1 (x);
-      return scm_from_bool (sgn < 0);
-    }
+    return scm_from_bool (scm_is_integer_negative_z (scm_bignum (x)));
   else if (SCM_REALP (x))
     return scm_from_bool(SCM_REAL_VALUE (x) < 0.0);
   else if (SCM_FRACTIONP (x))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]