I'm stumped on this right now, and I don't know why it's happening. In this class, I have a function that loops over all the numbers before a decimal point to cull extra zeroes off the end, and does it for the numbers after the decimal point as well. The second part (removing the extra zeroes before the decimal point) works fine, but the first part (removing the extra zeroes after the decimal point) doesn't.
I have to call the function multiple times for it to cull all of the extra zeroes on the right-hand end of the number, and I don't know why. I suspect it might have something to do with checking whether a byte is == 0, but I'm not sure yet.
FYI: The function is called in the constructor at the very end.
public class GiantNumber
{
//constructor and some other functions...
public bool IsNegative { get; }
public bool HasDecimal { get; }
public List<byte> NumbersBeforeDecimal;
public List<byte> NumbersAfterDecimal;
public void CullZeroes()
{
for (int i = 0; i < NumbersBeforeDecimal.Count; i++)
{
byte number = NumbersBeforeDecimal[i];
if (number == 0)
{
NumbersBeforeDecimal.RemoveAt(i);
}
else
{
break;
}
}
for (int i = NumbersAfterDecimal.Count - 1; i >= 0; i--)
{
byte number = NumbersAfterDecimal[i];
if (number == 0)
{
NumbersAfterDecimal.RemoveAt(i);
}
else
{
break;
}
}
}
}