// We already found the currency symbol. There should not be more currency symbols. Set
// We already found the currency symbol. There should not be more currency symbols. Set
// currSymbol to NULL so that we won't search it again in the later code path.
// currSymbol to NULL so that we won't search it again in the later code path.
p = next - 1;
p = next - 1;
}
}
else
else
{
{
break;
break;
}
}
}
}
ch = ++p < strEnd ? *p : '\0';
ch = ++p < strEnd ? *p : '\0';
}
}
int digCount = 0;
int digCount = 0;
int digEnd = 0;
int digEnd = 0;
int maxDigCount = number.Digits.Length - 1;
int maxDigCount = number.Digits.Length - 1;
int numberOfTrailingZeros = 0;
int numberOfTrailingZeros = 0;
while (true)
while (true)
{
{
if (IsDigit(ch))
if (IsDigit(ch))
{
{
state |= StateDigits;
state |= StateDigits;
if (ch != '0' || (state & StateNonZero) != 0)
if (ch != '0' || (state & StateNonZero) != 0)
{
{
if (digCount < maxDigCount)
if (digCount < maxDigCount)
{
{
number.Digits[digCount] = (byte)(ch);
number.Digits[digCount] = (byte)(ch);
if ((ch != '0') || (number.Kind != NumberBufferKind.Integer))
if ((ch != '0') || (number.Kind != NumberBufferKind.Integer))
{
{
digEnd = digCount + 1;
digEnd = digCount + 1;
}
}
}
}
else if (ch != '0')
else if (ch != '0')
{
{
// For decimal and binary floating-point numbers, we only
// For decimal and binary floating-point numbers, we only
// need to store digits up to maxDigCount. However, we still
// need to store digits up to maxDigCount. However, we still
// need to keep track of whether any additional digits past
// need to keep track of whether any additional digits past
// maxDigCount were non-zero, as that can impact rounding
// maxDigCount were non-zero, as that can impact rounding
// for an input that falls evenly between two representable
// for an input that falls evenly between two representable
// results.
// results.
number.HasNonZeroTail = true;
number.HasNonZeroTail = true;
}
}
if ((state & StateDecimal) == 0)
if ((state & StateDecimal) == 0)
{
{
number.Scale++;
number.Scale++;
}
}
if (digCount < maxDigCount)
if (digCount < maxDigCount)
{
{
// Handle a case like "53.0". We need to ignore trailing zeros in the fractional part for floating point numbers, so we keep a count of the number of trailing zeros and update digCount later
// Handle a case like "53.0". We need to ignore trailing zeros in the fractional part for floating point numbers, so we keep a count of the number of trailing zeros and update digCount later