mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
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.
This commit is contained in:
parent
124d889227
commit
f167627bb0
3 changed files with 7 additions and 6 deletions
|
@ -2696,8 +2696,8 @@ mpz_get_d_2exp (long *exp, mpz_srcptr z)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static double
|
double
|
||||||
bignum_frexp (struct scm_bignum *x, long *exp)
|
scm_integer_frexp_z (struct scm_bignum *x, long *exp)
|
||||||
{
|
{
|
||||||
mpz_t zx;
|
mpz_t zx;
|
||||||
alias_bignum_to_mpz (x, zx);
|
alias_bignum_to_mpz (x, zx);
|
||||||
|
@ -2730,7 +2730,7 @@ double
|
||||||
scm_integer_to_double_z (struct scm_bignum *x)
|
scm_integer_to_double_z (struct scm_bignum *x)
|
||||||
{
|
{
|
||||||
long exponent;
|
long exponent;
|
||||||
double significand = bignum_frexp (x, &exponent);
|
double significand = scm_integer_frexp_z (x, &exponent);
|
||||||
return ldexp (significand, exponent);
|
return ldexp (significand, exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3134,7 +3134,7 @@ scm_integer_inexact_sqrt_z (struct scm_bignum *k)
|
||||||
mpz_init (zs);
|
mpz_init (zs);
|
||||||
|
|
||||||
long expon;
|
long expon;
|
||||||
double signif = bignum_frexp (k, &expon);
|
double signif = scm_integer_frexp_z (k, &expon);
|
||||||
int negative = signif < 0;
|
int negative = signif < 0;
|
||||||
if (negative)
|
if (negative)
|
||||||
signif = -signif;
|
signif = -signif;
|
||||||
|
|
|
@ -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_positive_z (struct scm_bignum *x);
|
||||||
SCM_INTERNAL int scm_is_integer_negative_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 double scm_integer_to_double_z (struct scm_bignum *x);
|
||||||
SCM_INTERNAL SCM scm_integer_from_double (double val);
|
SCM_INTERNAL SCM scm_integer_from_double (double val);
|
||||||
|
|
||||||
|
|
|
@ -7209,11 +7209,11 @@ log_of_exact_integer (SCM n)
|
||||||
else if (SCM_BIGP (n))
|
else if (SCM_BIGP (n))
|
||||||
{
|
{
|
||||||
long expon;
|
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);
|
return log_of_shifted_double (signif, expon);
|
||||||
}
|
}
|
||||||
else
|
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 */
|
/* Returns log(n/d), for exact non-zero integers n and d */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue