Skip to content
This repository
Browse code

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
Watson authored January 10, 2012

Showing 1 changed file with 2 additions and 0 deletions. Show diff stats Hide diff stats

  1. 2  random.c
2  random.c
@@ -83,6 +83,8 @@ rand_init(struct MT *mt, VALUE vseed)
83 83
       case T_FIXNUM:
84 84
 	len = 1;
85 85
 	fixnum_seed = FIX2LONG(seed);
  86
+        if (fixnum_seed < 0)
  87
+            fixnum_seed = -fixnum_seed;
86 88
 	buf[0] = (unsigned int)(fixnum_seed & 0xffffffff);
87 89
 #if SIZEOF_LONG > SIZEOF_INT32
88 90
 	if ((long)(int)fixnum_seed != fixnum_seed) {

0 notes on commit 80d1bc1

Please sign in to comment.
Something went wrong with that request. Please try again.