summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-21 15:40:22 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-21 15:40:22 -0800
commitb4b045a8e7c65783d94812553e31ae0282e80cc4 (patch)
treedf16340ae5e8280f0ecdc36d2c7697fc478b96ec
parent13a8820a0979787bd16f530a400da69c798e954e (diff)
downloadtxr-b4b045a8e7c65783d94812553e31ae0282e80cc4.tar.gz
txr-b4b045a8e7c65783d94812553e31ae0282e80cc4.tar.bz2
txr-b4b045a8e7c65783d94812553e31ae0282e80cc4.zip
* arith.c (normalize): Linkage changed to extern.
* arith.h (normalize): Declared. * rand.c (random): Bugfix: normalize the bignum before returning it. * txr.1: Doc stubs for PRNG functionality.
-rw-r--r--ChangeLog10
-rw-r--r--arith.c2
-rw-r--r--arith.h1
-rw-r--r--rand.c2
-rw-r--r--txr.18
5 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3407d652..933d37f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2011-12-21 Kaz Kylheku <kaz@kylheku.com>
+ * arith.c (normalize): Linkage changed to extern.
+
+ * arith.h (normalize): Declared.
+
+ * rand.c (random): Bugfix: normalize the bignum before returning it.
+
+ * txr.1: Doc stubs for PRNG functionality.
+
+2011-12-21 Kaz Kylheku <kaz@kylheku.com>
+
* rand.c: Added comment about source of algorithm.
2011-12-21 Kaz Kylheku <kaz@kylheku.com>
diff --git a/arith.c b/arith.c
index 14696c24..8429f486 100644
--- a/arith.c
+++ b/arith.c
@@ -73,7 +73,7 @@ static val bignum_dbl_ipt(double_intptr_t di)
return n;
}
-static val normalize(val bignum)
+val normalize(val bignum)
{
if (mp_cmp_mag(mp(bignum), &NUM_MAX_MP) == MP_GT) {
return bignum;
diff --git a/arith.h b/arith.h
index ba8fd958..1b4026b1 100644
--- a/arith.h
+++ b/arith.h
@@ -25,4 +25,5 @@
*/
val make_bignum(void);
+val normalize(val bignum);
void arith_init(void);
diff --git a/rand.c b/rand.c
index 0b811b9f..2e504514 100644
--- a/rand.c
+++ b/rand.c
@@ -192,7 +192,7 @@ val random(val state, val modulus)
err = mp_mod(om, m, om);
if (err != MP_OKAY)
goto invalid;
- return out;
+ return normalize(out);
} else if (fixnump(modulus)) {
cnum m = c_num(modulus);
if (m <= 0)
diff --git a/txr.1 b/txr.1
index e064eed5..a8ea5aba 100644
--- a/txr.1
+++ b/txr.1
@@ -5708,6 +5708,14 @@ yields (1 2 3 4 5). In TXR Lisp, this usage can be simulated using
.SS Function interp-fun-p
+.SS Variable *random-state*
+
+.SS Function make-random-state
+
+.SS Function random-state-p
+
+.SS Functions random-fixnum and random
+
.SH APPENDIX A: NOTES ON EXOTIC REGULAR EXPRESSIONS
Users familiar with regular expressions may not be familiar with the complement