The zeros count for logcount on negatives can be done with mpz_hamdist by passing -1 for the second operand. This saves initializing and clearing a temporary mpz_t. * numbers.c (z_negative_one): New variable. (scm_init_numbers): Initialize it. (scm_logcount): Use it and mpz_hamdist to count zeros for negatives. * tests/numbers.test (logcount): More tests. I haven't changed the positive case, except to put it first and to share the scm_remember_upto, but a few tests of that won't go astray.