Browse Source

Fix `_random_u64`

gingerBill 2 years ago
parent
commit
67f48aca96
1 changed files with 4 additions and 3 deletions
  1. 4 3
      core/math/rand/rand.odin

+ 4 - 3
core/math/rand/rand.odin

@@ -135,11 +135,12 @@ _random_u64 :: proc(r: ^Rand) -> u64 {
 		}
 	}
 
+
 	old_state := r.state
 	r.state = old_state * 6364136223846793005 + (r.inc|1)
-	word := (((old_state >> 59) + 5) ~ old_state) * 12605985483714917081
-	rot := (word >> 43) ~ word
-	return (word >> rot) | (word << ((-rot) & 63))
+	xor_shifted := (((old_state >> 59) + 5) ~ old_state) * 12605985483714917081
+	rot := (old_state >> 59)
+	return (xor_shifted >> rot) | (xor_shifted << ((-rot) & 63))
 }
 
 /*