private static void AppendRadix(uint rem, uint radix, char[] tmp, StringBuilder buf, bool leadingZeros) {
const string symbols = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int digits = tmp.Length;
int i = digits;
while (i > 0 && (leadingZeros || rem != 0)) {
uint digit = rem % radix;
rem /= radix;
tmp[--i] = symbols[(int)digit];
}
if (leadingZeros) buf.Append(tmp);
else buf.Append(tmp, i, digits - i);
}