diff options
author | Andy Wingo <wingo@pobox.com> | 2021-12-19 14:43:05 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2022-01-13 09:37:16 +0100 |
commit | b41714d277b8d6629e358344b81d55b7ca4ef377 (patch) | |
tree | 35be04d6a920fc994cfea7af811c5fb590bd4732 /libguile/numbers.c | |
parent | 89cd48fcac6c8b11a1a1cb155d3ddf6747719e7c (diff) | |
download | guile-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/numbers.c')
-rw-r--r-- | libguile/numbers.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c index 548618e74..3e8431757 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -3177,22 +3177,12 @@ SCM_DEFINE (scm_lognot, "lognot", 1, 0, 0, "@end lisp") #define FUNC_NAME s_scm_lognot { - if (SCM_I_INUMP (n)) { - /* No overflow here, just need to toggle all the bits making up the inum. - Enhancement: No need to strip the tag and add it back, could just xor - a block of 1 bits, if that worked with the various debug versions of - the SCM typedef. */ - return SCM_I_MAKINUM (~ SCM_I_INUM (n)); - - } else if (SCM_BIGP (n)) { - SCM result = scm_i_mkbig (); - mpz_com (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n)); - scm_remember_upto_here_1 (n); - return result; - - } else { + if (SCM_I_INUMP (n)) + return scm_integer_lognot_i (SCM_I_INUM (n)); + else if (SCM_BIGP (n)) + return scm_integer_lognot_z (n); + else SCM_WRONG_TYPE_ARG (SCM_ARG1, n); - } } #undef FUNC_NAME |