Fix64 random fix

main
cosmonaut 2022-06-16 00:51:02 -07:00
parent ba662d7c3e
commit 2f5d25b458
1 changed files with 5 additions and 4 deletions

View File

@ -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)