summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--bignum.c5
2 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 633384c..28fe689 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Tue Jan 4 23:25:29 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_rand): should return positive random number.
+ [ruby-dev:25401]
+
+Tue Jan 4 11:15:29 2005 TAMURA Takashi <sheepman@tcn.zaq.ne.jp>
+
+ * bignum.c (rb_big_rand): do not use rb_big_modulo to generate
+ random bignums. [ruby-dev:25396]
+
Mon Jan 3 14:01:54 2005 Tanaka Akira <akr@m17n.org>
* random.c (random_seed): don't use /dev/urandom if it is not
diff --git a/bignum.c b/bignum.c
index aba88df..d823d9c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -2010,11 +2010,14 @@ rb_big_rand(max, rand_buf)
return rb_float_new(rand_buf[0]);
}
v = bignew(len,1);
+ RBIGNUM(v)->sign = RBIGNUM(max)->sign;
+ len--;
+ BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
while (len--) {
BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
}
- return rb_big_modulo((VALUE)v, max);
+ return v;
}
/*