mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-11-27 15:52:12 +00:00
18ac684607
--HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4020423
28 lines
756 B
C#
28 lines
756 B
C#
using System.Text;
|
|
|
|
namespace Jellyfish.Library
|
|
{
|
|
public static class StringBuilderExtensions
|
|
{
|
|
public static StringBuilder AppendWithoutGarbage(this StringBuilder builder, int number)
|
|
{
|
|
if (number < 0)
|
|
{
|
|
builder.Append('-');
|
|
}
|
|
|
|
int index = builder.Length;
|
|
do
|
|
{
|
|
builder.Insert(index, Digits, (number % 10) + 9, 1);
|
|
number /= 10;
|
|
}
|
|
while (number != 0);
|
|
|
|
return builder;
|
|
}
|
|
|
|
private static readonly char[] Digits = new char[] { '9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
|
}
|
|
}
|