Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use the absolute value of seed to make srand(-2**40) portable with 32…

…bit and 64bit
  • Loading branch information...
commit 80d1bc12708663ea70ff316b1762bdf126c04ccc 1 parent 18e269a
@Watson1978 Watson1978 authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  random.c
View
2  random.c
@@ -83,6 +83,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) {
Please sign in to comment.
Something went wrong with that request. Please try again.