some rng fixes

pull/5/head
cosmonaut 2023-10-06 13:38:17 -07:00
parent d1983bf168
commit 231575757e
1 changed files with 3 additions and 4 deletions

View File

@ -117,8 +117,7 @@ namespace MoonTools.ECS
public int Next(int n) public int Next(int n)
{ {
var next = NextInternal(); return (int) (((double) Next()) * n / int.MaxValue);
return (int) (((double) next) * n / uint.MaxValue);
} }
public int Next(int min, int max) public int Next(int min, int max)
@ -131,7 +130,7 @@ namespace MoonTools.ECS
public long NextInt64() public long NextInt64()
{ {
long next = NextInternal(); long next = NextInternal();
next <<= 32; next <<= 31;
next |= NextInternal(); next |= NextInternal();
return next; return next;
} }
@ -139,7 +138,7 @@ namespace MoonTools.ECS
public long NextInt64(long n) public long NextInt64(long n)
{ {
var next = NextInt64(); var next = NextInt64();
return (long) (((double) next) * n / ulong.MaxValue); return (long) (((double) next) * n / long.MaxValue);
} }
public long NextInt64(long min, long max) public long NextInt64(long min, long max)