diff options
author | Rob Browning <rlb@defaultvalue.org> | 2003-04-16 19:44:55 +0000 |
---|---|---|
committer | Rob Browning <rlb@defaultvalue.org> | 2003-04-16 19:44:55 +0000 |
commit | 0d79003d4431139307dcd0c14346d02bb9526ed8 (patch) | |
tree | d716610fef81e97c286581423ff0c420fd1cc356 /libguile/random.c | |
parent | b4fb7de8682c18b9ae4c1e3372e94bf640fed445 (diff) | |
download | guile-0d79003d4431139307dcd0c14346d02bb9526ed8.tar.gz |
* random.c (scm_c_random_bignum): use SCM_CHAR_BIT.
Diffstat (limited to 'libguile/random.c')
-rw-r--r-- | libguile/random.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libguile/random.c b/libguile/random.c index 9e453abca..a05b8ca63 100644 --- a/libguile/random.c +++ b/libguile/random.c @@ -251,9 +251,10 @@ scm_c_random_bignum (scm_t_rstate *state, SCM m) SCM result = scm_i_mkbig (); const size_t m_bits = mpz_sizeinbase (SCM_I_BIG_MPZ (m), 2); /* how many bits would only partially fill the last unsigned long? */ - const size_t end_bits = m_bits % (sizeof (unsigned long) * 8); + const size_t end_bits = m_bits % (sizeof (unsigned long) * SCM_CHAR_BIT); unsigned long *random_chunks = NULL; - const unsigned long num_full_chunks = m_bits / (sizeof (unsigned long) * 8); + const unsigned long num_full_chunks = + m_bits / (sizeof (unsigned long) * SCM_CHAR_BIT); const unsigned long num_chunks = num_full_chunks + ((end_bits) ? 1 : 0); /* we know the result will be this big */ @@ -275,7 +276,7 @@ scm_c_random_bignum (scm_t_rstate *state, SCM m) /* generate a mask with ones in the end_bits position, i.e. if end_bits is 3, then we'd have a mask of ...0000000111 */ const unsigned long rndbits = scm_the_rng.random_bits (state); - int rshift = (sizeof (unsigned long) * 8) - end_bits; + int rshift = (sizeof (unsigned long) * SCM_CHAR_BIT) - end_bits; unsigned long mask = ((unsigned long) ULONG_MAX) >> rshift; unsigned long highest_bits = rndbits & mask; *current_chunk-- = highest_bits; |