summaryrefslogtreecommitdiff
path: root/libguile/integers.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2022-01-05 21:12:01 +0100
committerAndy Wingo <wingo@pobox.com>2022-01-13 09:37:16 +0100
commit7c53325c31b86198b6c021c5c2b62c3742363619 (patch)
treeb608179140e6f2c8b9b70cc387fbb8700648db36 /libguile/integers.h
parentf2390e510fb9f5273b007a90270b5226115e5352 (diff)
downloadguile-7c53325c31b86198b6c021c5c2b62c3742363619.tar.gz
Fix scm_integer_to_double_z to always round; clean ups
* libguile/integers.c (scm_integer_to_double_z): Doubles that can't be exactly represented as integers should round. (bignum_frexp_z): New helper. (scm_integer_from_mpz, scm_integer_from_double): New internal functions. * libguile/numbers.h: * libguile/numbers.c (scm_i_bigcmp, scm_i_dbl2big, scm_i_dbl2num): Remove unused internal functions. (scm_inexact_to_exact): Rework to avoid scm_i_dbl2big. (scm_bigequal): Move here, from eq.c. (scm_integer_to_double_z): Use the new helper. (scm_i_big2dbl): Use scm_integer_to_double_z.
Diffstat (limited to 'libguile/integers.h')
-rw-r--r--libguile/integers.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libguile/integers.h b/libguile/integers.h
index 98c19b90f..bda575774 100644
--- a/libguile/integers.h
+++ b/libguile/integers.h
@@ -32,6 +32,8 @@ scm_bignum (SCM x)
return (struct scm_bignum *) SCM_UNPACK (x);
}
+SCM_INTERNAL SCM scm_integer_from_mpz (mpz_srcptr mpz);
+
SCM_INTERNAL int scm_is_integer_odd_i (scm_t_inum i);
SCM_INTERNAL int scm_is_integer_odd_z (struct scm_bignum *z);
@@ -167,6 +169,7 @@ 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_to_double_z (struct scm_bignum *x);
+SCM_INTERNAL SCM scm_integer_from_double (double val);
SCM_INTERNAL SCM scm_integer_add_ii (scm_t_inum x, scm_t_inum y);
SCM_INTERNAL SCM scm_integer_add_zi (struct scm_bignum *x, scm_t_inum y);