Browse Source

Fixed random number generation

Yentl Van Tendeloo 7 years ago
parent
commit
a1575e7851
1 changed files with 3 additions and 2 deletions
  1. 3 2
      bootstrap/random.alc

+ 3 - 2
bootstrap/random.alc

@@ -18,13 +18,14 @@ Float function random():
 	seed = integer_modulo(a * seed + c, m)
 
 	// The seed is the new value
-	return float_division(seed, m)!
+	return float_division(cast_float(seed), cast_float(m))!
 
 Integer function random_interval(a : Integer, b : Integer):
 	if (a == b):
 		return a!
 	else:
-		return cast_integer(random() * (b - a + 1) + a)!
+		log("Random gives us: " + cast_value(random()))
+		return cast_integer(random() * cast_float(b - a + 1) + cast_float(a))!
 
 Element function random_choice(list : Element):
 	if (list_len(list) == 0):