From 2f5d25b45872bd855f8f9beec202bc523b9f8d23 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Thu, 16 Jun 2022 00:51:02 -0700 Subject: [PATCH] Fix64 random fix --- src/Math/Fixed/Fix64.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Math/Fixed/Fix64.cs b/src/Math/Fixed/Fix64.cs index 050efa8a..9e8d19c5 100644 --- a/src/Math/Fixed/Fix64.cs +++ b/src/Math/Fixed/Fix64.cs @@ -62,11 +62,12 @@ namespace MoonWorks.Math.Fixed public static Fix64 Random(System.Random random, int max) { - var fractional = random.Next(); - var integral = random.Next(max); - long rawValue = (integral << FRACTIONAL_PLACES) + fractional; + return new Fix64(random.NextInt64(new Fix64(max).RawValue)); + } - return new Fix64(rawValue); + public static Fix64 Random(System.Random random, Fix64 max) + { + return new Fix64(random.NextInt64(max.RawValue)); } public static Fix64 Random(System.Random random, Fix64 min, Fix64 max)