private bool TryReadDecimalBits(int length, TdsParserStateObject stateObj, out int[] bits)
{
bits = stateObj._decimalBits; // used alloc'd array if we have one already
int i;
if (null == bits)
bits = new int[4];
else
{
for (i = 0; i < bits.Length; i++)
bits[i] = 0;
}
Debug.Assert((length > 0) &&
(length <= TdsEnums.MAX_NUMERIC_LEN - 1) &&
(length % 4 == 0), "decimal should have 4, 8, 12, or 16 bytes of data");
int decLength = length >> 2;
for (i = 0; i < decLength; i++)
{
// up to 16 bytes of data following the sign byte
if (!stateObj.TryReadInt32(out bits[i]))
{
return false;
}
}
return true;
}