summaryrefslogtreecommitdiff
path: root/libguile/integers.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-12-19 14:43:05 +0100
committerAndy Wingo <wingo@pobox.com>2022-01-13 09:37:16 +0100
commitb41714d277b8d6629e358344b81d55b7ca4ef377 (patch)
tree35be04d6a920fc994cfea7af811c5fb590bd4732 /libguile/integers.c
parent89cd48fcac6c8b11a1a1cb155d3ddf6747719e7c (diff)
downloadguile-b41714d277b8d6629e358344b81d55b7ca4ef377.tar.gz
Implement scm_lognot with new integer library
* libguile/integers.c (scm_integer_lognot_i, scm_integer_lognot_z): * libguile/integers.h: Declare the new internal functions. * libguile/numbers.c (scm_lognot): Use new internal functions.
Diffstat (limited to 'libguile/integers.c')
-rw-r--r--libguile/integers.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libguile/integers.c b/libguile/integers.c
index fc71c7acc..2ae2c30d5 100644
--- a/libguile/integers.c
+++ b/libguile/integers.c
@@ -2028,3 +2028,20 @@ scm_integer_logbit_uz (unsigned long index, SCM n)
scm_remember_upto_here_1 (n);
return val;
}
+
+SCM
+scm_integer_lognot_i (scm_t_inum n)
+{
+ return SCM_I_MAKINUM (~n);
+}
+
+SCM
+scm_integer_lognot_z (SCM n)
+{
+ mpz_t result, zn;
+ mpz_init (result);
+ alias_bignum_to_mpz (scm_bignum (n), zn);
+ mpz_com (result, zn);
+ scm_remember_upto_here_1 (n);
+ return take_mpz (result);
+}