diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-14 03:59:02 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-14 03:59:02 +0000 |
commit | 19f45f853c125ff744c53bd548f29f891c76c28b (patch) | |
tree | c32266f4b72a566688f4d26adabc6f2f3559457d /random.c | |
parent | 529ad093d42bd6ab802449747bf08a400563e12d (diff) | |
download | ruby-19f45f853c125ff744c53bd548f29f891c76c28b.tar.gz |
* bignum.c (rb_big_mul): faster multiplication by Karatsuba method and
twice faster square than normal multiplication.
* random.c (rb_rand_internal): used by Bignum#*.
* test/ruby/test_bignum.rb: add some tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r-- | random.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -452,6 +452,16 @@ limited_big_rand(struct MT *mt, struct RBignum *limit) return rb_big_norm((VALUE)val); } +unsigned long +rb_rand_internal(unsigned long i) +{ + struct MT *mt = &default_mt.mt; + if (!genrand_initialized(mt)) { + rand_init(mt, random_seed()); + } + return limited_rand(mt, i); +} + /* * call-seq: * rand(max=0) => number |