[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 57/85: Expose frexp from integers lib
From: |
Andy Wingo |
Subject: |
[Guile-commits] 57/85: Expose frexp from integers lib |
Date: |
Thu, 13 Jan 2022 03:40:23 -0500 (EST) |
wingo pushed a commit to branch main
in repository guile.
commit f167627bb06d09bcd20432ab25c2b0a4daf5c6fa
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Fri Jan 7 10:11:45 2022 +0100
Expose frexp from integers lib
* libguile/integers.h:
* libguile/integers.c (scm_integer_frexp_z): Expose internally.
(scm_integer_to_double_z):
(scm_integer_inexact_sqrt_z): Adapt uses.
* libguile/numbers.c (log_of_exact_integer): Use exposed
scm_integer_frexp_z.
---
libguile/integers.c | 8 ++++----
libguile/integers.h | 1 +
libguile/numbers.c | 4 ++--
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/libguile/integers.c b/libguile/integers.c
index 2fde52625..f60173649 100644
--- a/libguile/integers.c
+++ b/libguile/integers.c
@@ -2696,8 +2696,8 @@ mpz_get_d_2exp (long *exp, mpz_srcptr z)
}
#endif
-static double
-bignum_frexp (struct scm_bignum *x, long *exp)
+double
+scm_integer_frexp_z (struct scm_bignum *x, long *exp)
{
mpz_t zx;
alias_bignum_to_mpz (x, zx);
@@ -2730,7 +2730,7 @@ double
scm_integer_to_double_z (struct scm_bignum *x)
{
long exponent;
- double significand = bignum_frexp (x, &exponent);
+ double significand = scm_integer_frexp_z (x, &exponent);
return ldexp (significand, exponent);
}
@@ -3134,7 +3134,7 @@ scm_integer_inexact_sqrt_z (struct scm_bignum *k)
mpz_init (zs);
long expon;
- double signif = bignum_frexp (k, &expon);
+ double signif = scm_integer_frexp_z (k, &expon);
int negative = signif < 0;
if (negative)
signif = -signif;
diff --git a/libguile/integers.h b/libguile/integers.h
index 00706d553..1d406b659 100644
--- a/libguile/integers.h
+++ b/libguile/integers.h
@@ -169,6 +169,7 @@ SCM_INTERNAL int scm_is_integer_less_than_rz (double y,
struct scm_bignum *x);
SCM_INTERNAL int scm_is_integer_positive_z (struct scm_bignum *x);
SCM_INTERNAL int scm_is_integer_negative_z (struct scm_bignum *x);
+SCM_INTERNAL double scm_integer_frexp_z (struct scm_bignum *x, long *exp);
SCM_INTERNAL double scm_integer_to_double_z (struct scm_bignum *x);
SCM_INTERNAL SCM scm_integer_from_double (double val);
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 68534c02c..7eaac3dc4 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -7209,11 +7209,11 @@ log_of_exact_integer (SCM n)
else if (SCM_BIGP (n))
{
long expon;
- double signif = scm_i_big2dbl_2exp (n, &expon);
+ double signif = scm_integer_frexp_z (scm_bignum (n), &expon);
return log_of_shifted_double (signif, expon);
}
else
- scm_wrong_type_arg ("log_of_exact_integer", SCM_ARG1, n);
+ abort ();
}
/* Returns log(n/d), for exact non-zero integers n and d */
- [Guile-commits] 68/85: Bignums avoid both custom GMP allocator and finalizers, (continued)
- [Guile-commits] 68/85: Bignums avoid both custom GMP allocator and finalizers, Andy Wingo, 2022/01/13
- [Guile-commits] 69/85: take_mpz optimization, Andy Wingo, 2022/01/13
- [Guile-commits] 71/85: Re-rewrite integer-expt in C, Andy Wingo, 2022/01/13
- [Guile-commits] 73/85: Optimize scm_integer_mul_zz., Andy Wingo, 2022/01/13
- [Guile-commits] 84/85: Have log and log10(real nan) return real nan regardless of sign, Andy Wingo, 2022/01/13
- [Guile-commits] 85/85: Remove dead code in scm_integer_inexact_sqrt_z, Andy Wingo, 2022/01/13
- [Guile-commits] 24/85: Implement scm_logtest with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 13/85: Implement centered-quotient with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 23/85: Implement scm_logxor with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 19/85: Implement gcd with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 57/85: Expose frexp from integers lib,
Andy Wingo <=
- [Guile-commits] 59/85: divide2double refactor, Andy Wingo, 2022/01/13
- [Guile-commits] 60/85: Simplify scm_exact_integer_quotient, Andy Wingo, 2022/01/13
- [Guile-commits] 61/85: Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c, Andy Wingo, 2022/01/13
- [Guile-commits] 64/85: Avoid scm_i_mkbig outside numbers.c., Andy Wingo, 2022/01/13
- [Guile-commits] 78/85: Optimize bignum subtraction, Andy Wingo, 2022/01/13
- [Guile-commits] 70/85: Fix bug when making mpz from 0, Andy Wingo, 2022/01/13
- [Guile-commits] 83/85: Don't use HAVE_COPYSIGN in libguile/numbers.c, Andy Wingo, 2022/01/13
- [Guile-commits] 20/85: Implement lcm with new integer lib, Andy Wingo, 2022/01/13
- [Guile-commits] 22/85: Implement scm_logior with new integer library, Andy Wingo, 2022/01/13
- [Guile-commits] 30/85: Implement scm_bit_extract with new integer library, Andy Wingo, 2022/01/13