public static void Write(uint Value, char *Buffer, ref int BufferLength) { int Digits = NumberFormatHelper.GetDigitsCount(Value); int End = BufferLength + Digits; for (int Index = End - 1; Index >= BufferLength; Index--, Value /= 10) { Buffer[Index] = (char)(Value % 10 + '0'); } BufferLength += Digits; }
public static void Write(int Value, char *Buffer, ref int BufferLength, int GroupSize, string GroupSeparator) { if (Value < 0) { NumberFormatHelper.WriteNegativeSign(Buffer, ref BufferLength); Value = -Value; } int Digits = NumberFormatHelper.GetDigitsCount(Value); if (GroupSize >= Digits || GroupSize == 0) { int End = BufferLength + Digits; for (int Index = End - 1; Index >= BufferLength; Index--, Value /= 10) { Buffer[Index] = (char)(Value % 10 + '0'); } BufferLength = End; } else { Digits += ((Digits - 1) / GroupSize) * GroupSeparator.Length; int SeparatorStart = s_ArgsBufferLength; int SeparatorEnd = SeparatorStart; Write(GroupSeparator, s_ArgsBuffer, ref SeparatorEnd); int End = BufferLength + Digits; int Count = 0; for (int Index = End - 1; Index >= BufferLength; Index--, Value /= 10) { if (++Count > GroupSize) { for (int SeparatorIndex = SeparatorEnd - 1; SeparatorIndex >= SeparatorStart; SeparatorIndex--) { Buffer[Index--] = s_ArgsBuffer[SeparatorIndex]; } Count = 0; } Buffer[Index] = (char)(Value % 10 + '0'); } BufferLength = End; } }
public static void Write(long Value, char *Buffer, ref int BufferLength) { if (Value < 0) { NumberFormatHelper.WriteNegativeSign(Buffer, ref BufferLength); Value = -Value; } int Digits = NumberFormatHelper.GetDigitsCount(Value); int End = BufferLength + Digits; for (int Index = End - 1; Index >= BufferLength; Index--, Value /= 10) { Buffer[Index] = (char)(Value % 10 + '0'); } BufferLength += Digits; }