diff options
Diffstat (limited to 'random.scm')
-rw-r--r-- | random.scm | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -64,13 +64,15 @@ (do ((bln bitlen (+ -8 bln)) (rbs 0 (+ (arithmetic-shift rbs 8) (random:chunk state)))) ((<= bln 7) - (if (positive? bln) - (set! rbs (logxor (arithmetic-shift rbs bln) - (random:chunk state)))) - (if (< rbs modu) rbs (rnd))))) + (cond ((positive? bln) + (set! rbs (logxor (arithmetic-shift rbs bln) + (random:chunk state))) + (if (>= rbs modu) (rnd) rbs)) + ((>= rbs modu 1) (rnd)) + ((positive? modu) rbs) + (else (slib:error 'random 'not 'positive? modu)))))) (rnd)) - ;;@defvar *random-state* ;;Holds a data structure that encodes the internal state of the ;;random-number generator that @code{random} uses by default. The nature |