1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* random.c (rand_init): use the absolute value of seed to

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
This commit is contained in:
akr 2010-04-12 15:16:45 +00:00
parent 309077c9ae
commit 19afeacb88
2 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,9 @@
Tue Apr 13 00:12:04 2010 Tanaka Akira <akr@fsij.org>
* random.c (rand_init): use the absolute value of seed to
make srand(-2**40) portable with 32bit and 64bit.
[ruby-core:29292](2)
Mon Apr 12 22:48:47 2010 Tanaka Akira <akr@fsij.org>
* enumerator.c (inspect_enumerator): don't raise for uninitialized

View file

@ -376,6 +376,8 @@ rand_init(struct MT *mt, VALUE vseed)
case T_FIXNUM:
len = 1;
fixnum_seed = FIX2LONG(seed);
if (fixnum_seed < 0)
fixnum_seed = -fixnum_seed;
buf[0] = (unsigned int)(fixnum_seed & 0xffffffff);
#if SIZEOF_LONG > SIZEOF_INT32
if ((long)(int)fixnum_seed != fixnum_seed) {