* 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
This commit is contained in:
mame 2008-12-14 03:59:02 +00:00
parent 529ad093d4
commit 19f45f853c
4 changed files with 377 additions and 79 deletions

View file

@ -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