diff --git a/ASFFreeGames/RandomUtils.cs b/ASFFreeGames/RandomUtils.cs index 378d6aa..b4f8dec 100644 --- a/ASFFreeGames/RandomUtils.cs +++ b/ASFFreeGames/RandomUtils.cs @@ -43,9 +43,14 @@ private double NextDouble() { } Span bytes = stackalloc byte[16]; - Fill(bytes); Span ulongs = MemoryMarshal.Cast(bytes); - double u1 = ulongs[0] / (double) ulong.MaxValue; + double u1; + + do { + GetNonZeroBytes(bytes); + u1 = ulongs[0] / (double) ulong.MaxValue; + } while (u1 <= double.Epsilon); + double u2 = ulongs[1] / (double) ulong.MaxValue; // Box-Muller formula