aboutsummaryrefslogtreecommitdiffstats
path: root/random.c
Commit message (Collapse)AuthorAgeFilesLines
* * random.c (random_rand): add the result of random to thenobu2010-05-261-1/+1
| | | | | | | beginning of range, not the opposite. [ruby-dev:41415] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): subtraction method of non-numeric cannobu2010-05-261-3/+7
| | | | | | | | return Float, and add the result of random to the beginning of range, not the opposite. [ruby-dev:41410] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Documentation: change => in call-seq to ->.marcandre2010-05-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Harmonize "#=>" in examples. [ruby-core:30206] * bignum.c: ditto * class.c: ditto * compar.c: ditto * cont.c: ditto * dir.c: ditto * encoding.c: ditto * enum.c: ditto * enumerator.c: ditto * error.c: ditto * eval.c: ditto * file.c: ditto * gc.c: ditto * io.c: ditto * load.c: ditto * marshal.c: ditto * math.c: ditto * numeric.c: ditto * object.c: ditto * pack.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * range.c: ditto * re.c: ditto * ruby.c: ditto * signal.c: ditto * sprintf.c: ditto * string.c: ditto * struct.c: ditto * thread.c: ditto * time.c: ditto * transcode.c: ditto * variable.c: ditto * vm_eval.c: ditto * vm_method.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (make_seed_value): fix leading-zero-guard condition onnobu2010-04-131-2/+9
| | | | | | bdigit is smaller than 32bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): use the absolute value of seed toakr2010-04-121-0/+2
| | | | | | | | make srand(-2**40) portable with 32bit and 64bit. [ruby-core:29292](2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): ignore higher bits if all they are same asnobu2010-04-071-2/+6
| | | | | | the lower sign bit. [ruby-core:29292](2) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix rdoc. see r26808kazu2010-04-031-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): raise ArgumentError on nil, as thenobu2010-04-031-3/+2
| | | | | | | | | documentation implies. [ruby-core:29075] * random.c (rb_f_rand): mentioned the case of when max is nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: change include order; ruby.h should be at first.naruse2010-03-291-22/+23
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (default_rand): removed initial buffer.nobu2010-03-151-25/+34
| | | | | | | | | * random.c (Init_RandomSeed): initialize seed of default random. * random.c (Init_RandomSeed2): turn the seed to Bignum object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (next_state): no initialization here.nobu2010-03-151-23/+17
| | | | | | | * random.c (default_mt): always return initialized MT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_reset_random_seed): set seed in this. [ruby-core:28655]naruse2010-03-151-6/+22
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix rdoc.akr2010-03-031-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): don't use O_NOFOLLOW becauseakr2010-02-051-3/+0
| | | | | | | | | | /dev/urandom is a symlink in OpenSolaris. * lib/securerandom.rb (SecureRandom.random_bytes: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_hash_start): moved from string.c.nobu2009-11-031-9/+37
| | | | | | | | | * random.c (Init_RandomSeed2): register global address before set. * random.c (Init_RandomSeed): initialize hashseed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix typos.akr2009-11-031-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (rb_data_type_struct): constified dsize.nobu2009-09-091-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): fixed rdoc. [ruby-core:25332]nobu2009-09-031-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): random integer can be a fixnum fornobu2009-08-271-1/+1
| | | | | | | bignum range. [ruby-dev:39173] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): refined error message.nobu2009-08-261-9/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): fixed for edge cases of ranges.nobu2009-08-261-3/+7
| | | | | | | [ruby-dev:39166] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_rand): unified random_int and random_float.nobu2009-08-261-72/+156
| | | | | | | | [ruby-dev:39158]. and fixes [ruby-core:24655], [ruby-core:24677], [ruby-core:24679]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init, random_load): use already defined macro.nobu2009-08-251-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_int): arguments have to be converted tonobu2009-08-021-2/+3
| | | | | | | integer. [ruby-core:24679] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_int): prevent from GC.nobu2009-08-021-12/+17
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_float): rejects Infinity and NaN.nobu2009-08-011-0/+6
| | | | | | | [ruby-core:24651] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (init_genrand): ensure invariant of mt->next and mt->left.mame2009-07-301-1/+1
| | | | | | | | mt->next should always equal mt->state + N + 1 - mt->left. In fact, 'r = Random.new(0); r == r.dup' has returned false. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_bytes): use NUM2LONG instead of FIX2LONG becausemame2009-07-301-1/+1
| | | | | | | Random#bytes may receive bignum. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_{state,left}): internal/debug use.nobu2009-07-221-4/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): array length of random seed was broken, whichmame2009-07-211-4/+2
| | | | | | | | | causes memory error with srand(2**1000000-1). * test/ruby/test_rand.c: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c: workaround for VC++ 6.0.usa2009-07-181-1/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_{int32,real,bytes,int}): added functions fornobu2009-07-181-4/+25
| | | | | | | extension libraries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): needs wincrypt.h.nobu2009-07-181-1/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): use cryptographic service on Windows.nobu2009-07-181-0/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (DIGSPERINT): fix for LP64.nobu2009-07-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): /dev/urandom is not available onnobu2009-07-171-2/+8
| | | | | | | DOSISH systems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (random_equal): new method Random#==.nobu2009-07-171-0/+21
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (dump_mt): removed debug function.nobu2009-07-171-14/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): suppress a warning.nobu2009-07-161-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_random_t): objectified. [EXPERIMENTAL]nobu2009-07-161-45/+484
| | | | | | | [ruby-dev:30954] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): use fixed buffer for small numbers.nobu2009-07-111-31/+32
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (limited_rand): expands to long before shift so thatnobu2009-07-101-2/+2
| | | | | | | the result does not overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rand_init): got rid of buffer overflow.nobu2009-07-101-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (struct MT): ruby already assumes int has 32bit atnobu2009-07-101-48/+68
| | | | | | | | | least, so no needs to use long. * random.c (rand_init): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (fill_random_seed): enclosed conditionally usednobu2009-03-111-0/+2
| | | | | | | variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* stripped trailing spaces.nobu2009-02-221-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_write_error2, argf_next_argv), process.c (rb_fork_err),nobu2009-02-181-1/+1
| | | | | | | random.c (fill_random_seed): suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_f_srand): update RDoc. [ruby-core:21113]matz2009-01-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * random.c (rb_f_rand): type check simplified. strings are nomatz2008-12-291-35/+17
| | | | | | | | | longer allowed for argument. [ruby-dev:37655] * test/ruby/test_rand.rb (TestRand::o.to_int): need override to_int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_mul): faster multiplication by Karatsuba method andmame2008-12-141-0/+10
| | | | | | | | | | | 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