From: sheepman Date: 2005-01-04T11:19:50+09:00 Subject: [ruby-dev:25399] Re: rand uniformity こんにちは、sheepman です。 符合を忘れていました。 Index: bignum.c =================================================================== RCS file: /src/ruby/bignum.c,v retrieving revision 1.109 diff -u -r1.109 bignum.c --- bignum.c 3 Sep 2004 09:00:51 -0000 1.109 +++ bignum.c 4 Jan 2005 02:15:29 -0000 @@ -2015,11 +2015,14 @@ 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; } /* -- sheepman / TAMURA Takashi sheepman@tcn.zaq.ne.jp http://sheepman.parfait.ne.jp/