mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* 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:
parent
529ad093d4
commit
19f45f853c
4 changed files with 377 additions and 79 deletions
10
random.c
10
random.c
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue