mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
* 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
This commit is contained in:
parent
c664f0a534
commit
31f91eab5c
2 changed files with 14 additions and 1 deletions
10
ChangeLog
10
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
|
||||
|
|
5
bignum.c
5
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue