diff --git a/ChangeLog b/ChangeLog index d7b1164923..4f2c6da71d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Apr 13 00:12:04 2010 Tanaka Akira + + * 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 * enumerator.c (inspect_enumerator): don't raise for uninitialized diff --git a/random.c b/random.c index de047995d5..149069c76e 100644 --- a/random.c +++ b/random.c @@ -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) {