Ignore:
Timestamp:
Dec 22, 2009, 12:05:37 AM (10 years ago)
Author:
rme
Message:

In %bignum-random, call cl:random to generate a full digit's worth of
random bits. Neither the new generator nor the old one generates a full
32 random bits. (We do cheat a little with the current generator, but
it's not clear that our cheat is justifiable.)

It may be best to do bignums 16 bits at a time, just as we do on 32-bit
ports, at least until we put in a random number generator that
produces longer values.

One possible issue is that higher quality generators are more expensive
than the dead simple generator that we've historically used. It may be
worth a little bit shuffling effort to use all of the random bits we
get from the generator rather than throwing all but 16 of them out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new-random/level-0/l0-bignum64.lisp

    r13067 r13315  
    22272227    (with-bignum-buffers ((bignum ndigits))
    22282228      (dotimes (i sign-index)
    2229         (setf (bignum-ref bignum i) (%next-random-seed state)))
     2229        (setf (bignum-ref bignum i) (random (expt 2 digit-size) state)))
    22302230      (setf (bignum-ref bignum sign-index)
    22312231            (logand #x7fffffff (the (unsigned-byte 32)
    2232                                  (%next-random-seed state))))
     2232                                 (random (expt 2 (1- digit-size)) state))))
    22332233      (let* ((result (mod bignum number)))
    22342234        (if (eq result bignum)
Note: See TracChangeset for help on using the changeset viewer.