aboutsummaryrefslogtreecommitdiffstats
path: root/random.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:40 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:40 -0800
commit4684239efa63dc1b2c1cbe37ef7d3062029f5532 (patch)
tree606a687e9279e9bf6048925878968df9875a4973 /random.scm
parent64f037d91e0c9296dcaef9a0ff3eb33b19a2ed34 (diff)
downloadslib-4684239efa63dc1b2c1cbe37ef7d3062029f5532.tar.gz
slib-4684239efa63dc1b2c1cbe37ef7d3062029f5532.zip
Import Upstream version 3b1upstream/3b1
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