summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-04 14:28:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-01-04 14:28:24 +0000
commit31f91eab5cb8e66f0207fcce6afe75b93057834a (patch)
tree4fb93e521ddaadb1e8c2440b46dceda9dc16fb46 /bignum.c
parentc664f0a534dd0912161106f1503fe6d7fc92a2fd (diff)
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401] * bignum.c (rb_big_rand): do not use rb_big_modulo to generate random bignums. [ruby-dev:25396] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c5
1 files changed, 4 insertions, 1 deletions
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;
}
/*