diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-04 14:28:24 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-01-04 14:28:24 +0000 |
commit | 31f91eab5cb8e66f0207fcce6afe75b93057834a (patch) | |
tree | 4fb93e521ddaadb1e8c2440b46dceda9dc16fb46 /bignum.c | |
parent | c664f0a534dd0912161106f1503fe6d7fc92a2fd (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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } /* |