aboutsummaryrefslogtreecommitdiffstats
path: root/random.scm
diff options
context:
space:
mode:
Diffstat (limited to 'random.scm')
-rw-r--r--random.scm12
1 files changed, 7 insertions, 5 deletions
diff --git a/random.scm b/random.scm
index a6259f6..f4b2abb 100644
--- a/random.scm
+++ b/random.scm
@@ -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