Percent.One bugfix

This commit is contained in:
Justin Swanson 2020-02-27 20:43:30 -06:00
parent ef36a06be9
commit 033e829612

View File

@ -6,11 +6,11 @@ namespace Wabbajack.Common
{
public struct Percent : IComparable, IEquatable<Percent>
{
public static readonly Percent One = new Percent(1);
public static readonly Percent Zero = new Percent(0);
public static readonly Percent One = new Percent(1d);
public static readonly Percent Zero = new Percent(0d);
public readonly double Value;
public Percent Inverse => new Percent(1 - this.Value, check: false);
public Percent Inverse => new Percent(1d - this.Value, check: false);
private Percent(double d, bool check)
{
@ -24,9 +24,10 @@ namespace Wabbajack.Common
}
}
public Percent(long max, long current) : this((double)current / max)
public Percent(long max, long current)
: this((double)current / max)
{
}
public Percent(double d)
@ -34,22 +35,6 @@ namespace Wabbajack.Common
{
}
public Percent(int i)
{
if (i < 0)
{
Value = 0;
}
else if (i > 100)
{
Value = 1;
}
else
{
Value = i / 100d;
}
}
public static bool InRange(double d)
{
return d >= 0 || d <= 1;