From 231575757e70b99dacea66f9cb4e42316703215d Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 6 Oct 2023 13:38:17 -0700 Subject: [PATCH] some rng fixes --- src/Random.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Random.cs b/src/Random.cs index 0779e46..0a38c21 100644 --- a/src/Random.cs +++ b/src/Random.cs @@ -117,8 +117,7 @@ namespace MoonTools.ECS public int Next(int n) { - var next = NextInternal(); - return (int) (((double) next) * n / uint.MaxValue); + return (int) (((double) Next()) * n / int.MaxValue); } public int Next(int min, int max) @@ -131,7 +130,7 @@ namespace MoonTools.ECS public long NextInt64() { long next = NextInternal(); - next <<= 32; + next <<= 31; next |= NextInternal(); return next; } @@ -139,7 +138,7 @@ namespace MoonTools.ECS public long NextInt64(long n) { var next = NextInt64(); - return (long) (((double) next) * n / ulong.MaxValue); + return (long) (((double) next) * n / long.MaxValue); } public long NextInt64(long min, long max)