diff --git a/src/BizHawk.Common/Extensions/NumberExtensions.cs b/src/BizHawk.Common/Extensions/NumberExtensions.cs
index 8dad23a325..987579d6b0 100644
--- a/src/BizHawk.Common/Extensions/NumberExtensions.cs
+++ b/src/BizHawk.Common/Extensions/NumberExtensions.cs
@@ -127,15 +127,20 @@ namespace BizHawk.Common.NumberExtensions
}
}
+ ///
+ /// -1 when when is negative or 0,
+ /// otherwise the (floor of the) base-10 logarithm of that value i.e. 1 less than the number of decimal digits
+ ///
public static int Log10(int i)
{
+ if (i <= 0) return -1;
var toReturn = 0;
- while (i > 100)
+ while (i >= 100)
{
i /= 100;
toReturn += 2;
}
- return i > 10 ? toReturn + 1 : toReturn;
+ return i >= 10 ? toReturn + 1 : toReturn;
}
///