diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | arith.c | 2 | ||||
-rw-r--r-- | arith.h | 1 | ||||
-rw-r--r-- | rand.c | 2 | ||||
-rw-r--r-- | txr.1 | 8 |
5 files changed, 21 insertions, 2 deletions
@@ -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> @@ -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; @@ -25,4 +25,5 @@ */ val make_bignum(void); +val normalize(val bignum); void arith_init(void); @@ -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) @@ -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 |