summaryrefslogtreecommitdiff
path: root/libguile/numbers.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-12-19 11:06:36 +0100
committerAndy Wingo <wingo@pobox.com>2022-01-13 09:37:16 +0100
commit89cd48fcac6c8b11a1a1cb155d3ddf6747719e7c (patch)
tree1a429a377d5f2fa90c9284d0b148a1d30160dcd7 /libguile/numbers.c
parent6298d731155ea35aecf68f21af81f1c4fd2f5e87 (diff)
downloadguile-89cd48fcac6c8b11a1a1cb155d3ddf6747719e7c.tar.gz
Implement scm_logbit_p with new integer library
* libguile/integers.c (scm_integer_logbit_ui, scm_integer_logbit_uz): * libguile/integers.h: Declare the new internal functions. * libguile/numbers.c (scm_logbit_p): Use new internal functions.
Diffstat (limited to 'libguile/numbers.c')
-rw-r--r--libguile/numbers.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 26d1c061f..548618e74 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -3155,23 +3155,9 @@ SCM_DEFINE (scm_logbit_p, "logbit?", 2, 0, 0,
iindex = scm_to_ulong (index);
if (SCM_I_INUMP (j))
- {
- if (iindex < SCM_LONG_BIT - 1)
- /* Arrange for the number to be converted to unsigned before
- checking the bit, to ensure that we're testing the bit in a
- two's complement representation (regardless of the native
- representation. */
- return scm_from_bool ((1UL << iindex) & SCM_I_INUM (j));
- else
- /* Portably check the sign. */
- return scm_from_bool (SCM_I_INUM (j) < 0);
- }
+ return scm_from_bool (scm_integer_logbit_ui (iindex, SCM_I_INUM (j)));
else if (SCM_BIGP (j))
- {
- int val = mpz_tstbit (SCM_I_BIG_MPZ (j), iindex);
- scm_remember_upto_here_1 (j);
- return scm_from_bool (val);
- }
+ return scm_from_bool (scm_integer_logbit_uz (iindex, j));
else
SCM_WRONG_TYPE_ARG (SCM_ARG2, j);
}