1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 18:20:22 +02:00

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.
This commit is contained in:
Andy Wingo 2021-12-19 14:43:05 +01:00
parent 89cd48fcac
commit b41714d277
3 changed files with 25 additions and 15 deletions

View file

@ -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);
}