[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 62/69: Remove last non-admin SCM_I_BIG_MPZ uses in numbe
From: |
Andy Wingo |
Subject: |
[Guile-commits] 62/69: Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c |
Date: |
Fri, 7 Jan 2022 08:27:25 -0500 (EST) |
wingo pushed a commit to branch wip-inline-digits
in repository guile.
commit 33bf14c84294e66fe492a219bdf6b7d4b3467757
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Fri Jan 7 11:21:41 2022 +0100
Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c
* libguile/numbers.c (scm_magnitude, scm_angle): Use integers lib.
---
libguile/numbers.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 280a91ab4..9575df09c 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -6327,12 +6327,10 @@ SCM_PRIMITIVE_GENERIC (scm_magnitude, "magnitude", 1,
0, 0,
}
else if (SCM_BIGP (z))
{
- int sgn = mpz_sgn (SCM_I_BIG_MPZ (z));
- scm_remember_upto_here_1 (z);
- if (sgn < 0)
- return scm_i_clonebig (z, 0);
+ if (scm_is_integer_negative_z (scm_bignum (z)))
+ return scm_integer_negate_z (scm_bignum (z));
else
- return z;
+ return z;
}
else if (SCM_REALP (z))
return scm_i_from_double (fabs (SCM_REAL_VALUE (z)));
@@ -6371,9 +6369,7 @@ SCM_PRIMITIVE_GENERIC (scm_angle, "angle", 1, 0, 0,
}
else if (SCM_BIGP (z))
{
- int sgn = mpz_sgn (SCM_I_BIG_MPZ (z));
- scm_remember_upto_here_1 (z);
- if (sgn < 0)
+ if (scm_is_integer_negative_z (scm_bignum (z)))
return scm_i_from_double (atan2 (0.0, -1.0));
else
return flo0;
- [Guile-commits] 65/69: Avoid scm_i_mkbig outside numbers.c., (continued)
- [Guile-commits] 65/69: Avoid scm_i_mkbig outside numbers.c., Andy Wingo, 2022/01/07
- [Guile-commits] 57/69: Refactor scm_sqrt in terms of integers.[ch], Andy Wingo, 2022/01/07
- [Guile-commits] 59/69: Remove dead bignum frexp code from numbers.c, Andy Wingo, 2022/01/07
- [Guile-commits] 47/69: Fix deprecated bit-count* when counting 0 bits, Andy Wingo, 2022/01/07
- [Guile-commits] 49/69: Reimplement scm_is_{un, }signed_integer for bignums, Andy Wingo, 2022/01/07
- [Guile-commits] 51/69: Reimplement scm_{to,from}_{int32,uint32}, Andy Wingo, 2022/01/07
- [Guile-commits] 45/69: Remove support for allowing exact numbers to be divided by zero, Andy Wingo, 2022/01/07
- [Guile-commits] 50/69: Reimplement scm_from_int8 etc, Andy Wingo, 2022/01/07
- [Guile-commits] 56/69: Reimplement exact-integer-sqrt with integers.[ch], Andy Wingo, 2022/01/07
- [Guile-commits] 55/69: scm_to_mpz uses integer lib, Andy Wingo, 2022/01/07
- [Guile-commits] 62/69: Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c,
Andy Wingo <=
- [Guile-commits] 61/69: Simplify scm_exact_integer_quotient, Andy Wingo, 2022/01/07
- [Guile-commits] 63/69: Simplify magnitude, angle, Andy Wingo, 2022/01/07
- [Guile-commits] 64/69: Use scm_integer_to_double_z in numbers.c instead of big2dbl, Andy Wingo, 2022/01/07
- [Guile-commits] 67/69: Finish srfi-60 port off old scm mpz API, Andy Wingo, 2022/01/07
- [Guile-commits] 66/69: Start porting srfi-60 off the bad bignum interfaces, Andy Wingo, 2022/01/07
- [Guile-commits] 69/69: Bignums avoid both custom GMP allocator and finalizers, Andy Wingo, 2022/01/07
- [Guile-commits] 68/69: scm_to_ipv6 uses scm_to_mpz, Andy Wingo, 2022/01/07