Add `Log10(int)` helper
This commit is contained in:
parent
6049d5e4f5
commit
fbd45915cb
|
@ -296,7 +296,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
/// <returns><paramref name="index"/> with leading zeroes such that every frame in the movie will be printed with the same number of digits</returns>
|
||||
private string FrameToStringPadded(int index)
|
||||
=> index.ToString(_formatCache[(int)Math.Log10(Math.Max(CurrentTasMovie.InputLogLength, 1))]);
|
||||
=> index.ToString(_formatCache[NumberExtensions.Log10(Math.Max(CurrentTasMovie.InputLogLength, 1))]);
|
||||
|
||||
private void TasView_QueryItemText(int index, RollColumn column, out string text, ref int offsetX, ref int offsetY)
|
||||
{
|
||||
|
|
|
@ -127,6 +127,17 @@ namespace BizHawk.Common.NumberExtensions
|
|||
}
|
||||
}
|
||||
|
||||
public static int Log10(int i)
|
||||
{
|
||||
var toReturn = 0;
|
||||
while (i > 100)
|
||||
{
|
||||
i /= 100;
|
||||
toReturn += 2;
|
||||
}
|
||||
return i > 10 ? toReturn + 1 : toReturn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receives a number and returns the number of hexadecimal digits it is
|
||||
/// Note: currently only returns 2, 4, 6, or 8
|
||||
|
|
Loading…
Reference in New Issue