Fix Index out of range in .ToDisplayString()
This commit is contained in:
parent
2047f25e4e
commit
ed39b8e847
|
@ -19,12 +19,12 @@ public abstract class Unit
|
|||
|
||||
var i = 8;
|
||||
|
||||
while (a >= 10000)
|
||||
while (a >= 10000 && i < MaxPrefix)
|
||||
{
|
||||
a /= 1000;
|
||||
i++;
|
||||
}
|
||||
while (a < 10)
|
||||
while (a < 10 && i > 0)
|
||||
{
|
||||
a *= 1000;
|
||||
i--;
|
||||
|
@ -38,5 +38,7 @@ public abstract class Unit
|
|||
}
|
||||
|
||||
private static readonly IReadOnlyList<String> Prefix = new[] { "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Y" };
|
||||
|
||||
private static Int32 MaxPrefix { get; } = Prefix.Count - 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue