using System; using System.Globalization; using System.Runtime.CompilerServices; using System.Text; using System.Threading; namespace System { // Token: 0x02000698 RID: 1688 internal sealed class NumberFormatter { // Token: 0x06003FEB RID: 16363 RVA: 0x000D7B54 File Offset: 0x000D5D54 public NumberFormatter(Thread current) { this._cbuf = new char[0]; if (current == null) { return; } this._thread = current; this.CurrentCulture = this._thread.CurrentCulture; } // Token: 0x06003FEC RID: 16364 RVA: 0x000D7B88 File Offset: 0x000D5D88 static NumberFormatter() { NumberFormatter.GetFormatterTables(out NumberFormatter.MantissaBitsTable, out NumberFormatter.TensExponentTable, out NumberFormatter.DigitLowerTable, out NumberFormatter.DigitUpperTable, out NumberFormatter.TenPowersList, out NumberFormatter.DecHexDigits); } // Token: 0x06003FED RID: 16365 [MethodImpl(MethodImplOptions.InternalCall)] private unsafe static extern void GetFormatterTables(out ulong* MantissaBitsTable, out int* TensExponentTable, out char* DigitLowerTable, out char* DigitUpperTable, out long* TenPowersList, out int* DecHexDigits); // Token: 0x06003FEE RID: 16366 RVA: 0x000D7BB0 File Offset: 0x000D5DB0 private unsafe static long GetTenPowerOf(int i) { return NumberFormatter.TenPowersList[i]; } // Token: 0x06003FEF RID: 16367 RVA: 0x000D7BBC File Offset: 0x000D5DBC private void InitDecHexDigits(uint value) { if (value >= 100000000U) { int num = (int)(value / 100000000U); value -= (uint)(100000000 * num); this._val2 = NumberFormatter.FastToDecHex(num); } this._val1 = NumberFormatter.ToDecHex((int)value); } // Token: 0x06003FF0 RID: 16368 RVA: 0x000D7C00 File Offset: 0x000D5E00 private void InitDecHexDigits(ulong value) { if (value >= 100000000UL) { long num = (long)(value / 100000000UL); value -= (ulong)(100000000L * num); if (num >= 100000000L) { int num2 = (int)(num / 100000000L); num -= (long)num2 * 100000000L; this._val3 = NumberFormatter.ToDecHex(num2); } if (num != 0L) { this._val2 = NumberFormatter.ToDecHex((int)num); } } if (value != 0UL) { this._val1 = NumberFormatter.ToDecHex((int)value); } } // Token: 0x06003FF1 RID: 16369 RVA: 0x000D7C84 File Offset: 0x000D5E84 private void InitDecHexDigits(uint hi, ulong lo) { if (hi == 0U) { this.InitDecHexDigits(lo); return; } uint num = hi / 100000000U; ulong num2 = (ulong)(hi - num * 100000000U); ulong num3 = lo / 100000000UL; ulong num4 = lo - num3 * 100000000UL + num2 * 9551616UL; hi = num; lo = num3 + num2 * 184467440737UL; num3 = num4 / 100000000UL; num4 -= num3 * 100000000UL; lo += num3; this._val1 = NumberFormatter.ToDecHex((int)num4); num3 = lo / 100000000UL; num4 = lo - num3 * 100000000UL; lo = num3; if (hi != 0U) { lo += (ulong)hi * 184467440737UL; num4 += (ulong)hi * 9551616UL; num3 = num4 / 100000000UL; lo += num3; num4 -= num3 * 100000000UL; } this._val2 = NumberFormatter.ToDecHex((int)num4); if (lo >= 100000000UL) { num3 = lo / 100000000UL; lo -= num3 * 100000000UL; this._val4 = NumberFormatter.ToDecHex((int)num3); } this._val3 = NumberFormatter.ToDecHex((int)lo); } // Token: 0x06003FF2 RID: 16370 RVA: 0x000D7DA4 File Offset: 0x000D5FA4 private unsafe static uint FastToDecHex(int val) { if (val < 100) { return (uint)NumberFormatter.DecHexDigits[val]; } int num = val * 5243 >> 19; return (uint)((NumberFormatter.DecHexDigits[num] << 8) | NumberFormatter.DecHexDigits[val - num * 100]); } // Token: 0x06003FF3 RID: 16371 RVA: 0x000D7DEC File Offset: 0x000D5FEC private static uint ToDecHex(int val) { uint num = 0U; if (val >= 10000) { int num2 = val / 10000; val -= num2 * 10000; num = NumberFormatter.FastToDecHex(num2) << 16; } return num | NumberFormatter.FastToDecHex(val); } // Token: 0x06003FF4 RID: 16372 RVA: 0x000D7E2C File Offset: 0x000D602C private static int FastDecHexLen(int val) { if (val < 256) { if (val < 16) { return 1; } return 2; } else { if (val < 4096) { return 3; } return 4; } } // Token: 0x06003FF5 RID: 16373 RVA: 0x000D7E54 File Offset: 0x000D6054 private static int DecHexLen(uint val) { if (val < 65536U) { return NumberFormatter.FastDecHexLen((int)val); } return 4 + NumberFormatter.FastDecHexLen((int)(val >> 16)); } // Token: 0x06003FF6 RID: 16374 RVA: 0x000D7E74 File Offset: 0x000D6074 private int DecHexLen() { if (this._val4 != 0U) { return NumberFormatter.DecHexLen(this._val4) + 24; } if (this._val3 != 0U) { return NumberFormatter.DecHexLen(this._val3) + 16; } if (this._val2 != 0U) { return NumberFormatter.DecHexLen(this._val2) + 8; } if (this._val1 != 0U) { return NumberFormatter.DecHexLen(this._val1); } return 0; } // Token: 0x06003FF7 RID: 16375 RVA: 0x000D7EE8 File Offset: 0x000D60E8 private static int ScaleOrder(long hi) { for (int i = 18; i >= 0; i--) { if (hi >= NumberFormatter.GetTenPowerOf(i)) { return i + 1; } } return 1; } // Token: 0x06003FF8 RID: 16376 RVA: 0x000D7F1C File Offset: 0x000D611C private int InitialFloatingPrecision() { if (this._specifier == 'R') { return this._defPrecision + 2; } if (this._precision < this._defPrecision) { return this._defPrecision; } if (this._specifier == 'G') { return Math.Min(this._defPrecision + 2, this._precision); } if (this._specifier == 'E') { return Math.Min(this._defPrecision + 2, this._precision + 1); } return this._defPrecision; } // Token: 0x06003FF9 RID: 16377 RVA: 0x000D7FA4 File Offset: 0x000D61A4 private static int ParsePrecision(string format) { int num = 0; for (int i = 1; i < format.Length; i++) { int num2 = (int)(format[i] - '0'); num = num * 10 + num2; if (num2 < 0 || num2 > 9 || num > 99) { return -2; } } return num; } // Token: 0x06003FFA RID: 16378 RVA: 0x000D7FF8 File Offset: 0x000D61F8 private void Init(string format) { this._val1 = (this._val2 = (this._val3 = (this._val4 = 0U))); this._offset = 0; this._NaN = (this._infinity = false); this._isCustomFormat = false; this._specifierIsUpper = true; this._precision = -1; if (format == null || format.Length == 0) { this._specifier = 'G'; return; } char c = format[0]; if (c >= 'a' && c <= 'z') { c = c - 'a' + 'A'; this._specifierIsUpper = false; } else if (c < 'A' || c > 'Z') { this._isCustomFormat = true; this._specifier = '0'; return; } this._specifier = c; if (format.Length > 1) { this._precision = NumberFormatter.ParsePrecision(format); if (this._precision == -2) { this._isCustomFormat = true; this._specifier = '0'; this._precision = -1; } } } // Token: 0x06003FFB RID: 16379 RVA: 0x000D80FC File Offset: 0x000D62FC private void InitHex(ulong value) { int defPrecision = this._defPrecision; switch (defPrecision) { case 3: value = (ulong)((byte)value); break; default: if (defPrecision == 10) { value = (ulong)((uint)value); } break; case 5: value = (ulong)((ushort)value); break; } this._val1 = (uint)value; this._val2 = (uint)(value >> 32); this._decPointPos = (this._digitsLen = this.DecHexLen()); if (value == 0UL) { this._decPointPos = 1; } } // Token: 0x06003FFC RID: 16380 RVA: 0x000D8184 File Offset: 0x000D6384 private void Init(string format, int value, int defPrecision) { this.Init(format); this._defPrecision = defPrecision; this._positive = value >= 0; if (value == 0 || this._specifier == 'X') { this.InitHex((ulong)((long)value)); return; } if (value < 0) { value = -value; } this.InitDecHexDigits((uint)value); this._decPointPos = (this._digitsLen = this.DecHexLen()); } // Token: 0x06003FFD RID: 16381 RVA: 0x000D81F0 File Offset: 0x000D63F0 private void Init(string format, uint value, int defPrecision) { this.Init(format); this._defPrecision = defPrecision; this._positive = true; if (value == 0U || this._specifier == 'X') { this.InitHex((ulong)value); return; } this.InitDecHexDigits(value); this._decPointPos = (this._digitsLen = this.DecHexLen()); } // Token: 0x06003FFE RID: 16382 RVA: 0x000D824C File Offset: 0x000D644C private void Init(string format, long value) { this.Init(format); this._defPrecision = 19; this._positive = value >= 0L; if (value == 0L || this._specifier == 'X') { this.InitHex((ulong)value); return; } if (value < 0L) { value = -value; } this.InitDecHexDigits((ulong)value); this._decPointPos = (this._digitsLen = this.DecHexLen()); } // Token: 0x06003FFF RID: 16383 RVA: 0x000D82BC File Offset: 0x000D64BC private void Init(string format, ulong value) { this.Init(format); this._defPrecision = 20; this._positive = true; if (value == 0UL || this._specifier == 'X') { this.InitHex(value); return; } this.InitDecHexDigits(value); this._decPointPos = (this._digitsLen = this.DecHexLen()); } // Token: 0x06004000 RID: 16384 RVA: 0x000D8318 File Offset: 0x000D6518 private unsafe void Init(string format, double value, int defPrecision) { this.Init(format); this._defPrecision = defPrecision; long num = BitConverter.DoubleToInt64Bits(value); this._positive = num >= 0L; num &= long.MaxValue; if (num == 0L) { this._decPointPos = 1; this._digitsLen = 0; this._positive = true; return; } int num2 = (int)(num >> 52); long num3 = num & 4503599627370495L; if (num2 == 2047) { this._NaN = num3 != 0L; this._infinity = num3 == 0L; return; } int num4 = 0; if (num2 == 0) { num2 = 1; int num5 = NumberFormatter.ScaleOrder(num3); if (num5 < 15) { num4 = num5 - 15; num3 *= NumberFormatter.GetTenPowerOf(-num4); } } else { num3 = (num3 + 4503599627370495L + 1L) * 10L; num4 = -1; } ulong num6 = (ulong)((uint)num3); ulong num7 = (ulong)num3 >> 32; ulong num8 = NumberFormatter.MantissaBitsTable[num2]; ulong num9 = num8 >> 32; num8 = (ulong)((uint)num8); ulong num10 = num7 * num8 + num6 * num9 + (num6 * num8 >> 32); long num11 = (long)(num7 * num9 + (num10 >> 32)); while (num11 < 10000000000000000L) { num10 = (num10 & (ulong)(-1)) * 10UL; num11 = num11 * 10L + (long)(num10 >> 32); num4--; } if ((num10 & (ulong)(-2147483648)) != 0UL) { num11 += 1L; } int num12 = 17; this._decPointPos = NumberFormatter.TensExponentTable[num2] + num4 + num12; int num13 = this.InitialFloatingPrecision(); if (num12 > num13) { long tenPowerOf = NumberFormatter.GetTenPowerOf(num12 - num13); num11 = (num11 + (tenPowerOf >> 1)) / tenPowerOf; num12 = num13; } if (num11 >= NumberFormatter.GetTenPowerOf(num12)) { num12++; this._decPointPos++; } this.InitDecHexDigits((ulong)num11); this._offset = this.CountTrailingZeros(); this._digitsLen = num12 - this._offset; } // Token: 0x06004001 RID: 16385 RVA: 0x000D8508 File Offset: 0x000D6708 private void Init(string format, decimal value) { this.Init(format); this._defPrecision = 100; int[] bits = decimal.GetBits(value); int num = (bits[3] & 2031616) >> 16; this._positive = bits[3] >= 0; if (bits[0] == 0 && bits[1] == 0 && bits[2] == 0) { this._decPointPos = -num; this._positive = true; this._digitsLen = 0; return; } this.InitDecHexDigits((uint)bits[2], (ulong)(((long)bits[1] << 32) | (long)((ulong)bits[0]))); this._digitsLen = this.DecHexLen(); this._decPointPos = this._digitsLen - num; if (this._precision != -1 || this._specifier != 'G') { this._offset = this.CountTrailingZeros(); this._digitsLen -= this._offset; } } // Token: 0x06004002 RID: 16386 RVA: 0x000D85E0 File Offset: 0x000D67E0 private void ResetCharBuf(int size) { this._ind = 0; if (this._cbuf.Length < size) { this._cbuf = new char[size]; } } // Token: 0x06004003 RID: 16387 RVA: 0x000D8604 File Offset: 0x000D6804 private void Resize(int len) { char[] array = new char[len]; Array.Copy(this._cbuf, array, this._ind); this._cbuf = array; } // Token: 0x06004004 RID: 16388 RVA: 0x000D8634 File Offset: 0x000D6834 private void Append(char c) { if (this._ind == this._cbuf.Length) { this.Resize(this._ind + 10); } this._cbuf[this._ind++] = c; } // Token: 0x06004005 RID: 16389 RVA: 0x000D867C File Offset: 0x000D687C private void Append(char c, int cnt) { if (this._ind + cnt > this._cbuf.Length) { this.Resize(this._ind + cnt + 10); } while (cnt-- > 0) { this._cbuf[this._ind++] = c; } } // Token: 0x06004006 RID: 16390 RVA: 0x000D86DC File Offset: 0x000D68DC private void Append(string s) { int length = s.Length; if (this._ind + length > this._cbuf.Length) { this.Resize(this._ind + length + 10); } for (int i = 0; i < length; i++) { this._cbuf[this._ind++] = s[i]; } } // Token: 0x06004007 RID: 16391 RVA: 0x000D8748 File Offset: 0x000D6948 private NumberFormatInfo GetNumberFormatInstance(IFormatProvider fp) { if (this._nfi != null && fp == null) { return this._nfi; } return NumberFormatInfo.GetInstance(fp); } // Token: 0x17000BDA RID: 3034 // (set) Token: 0x06004008 RID: 16392 RVA: 0x000D8768 File Offset: 0x000D6968 public CultureInfo CurrentCulture { set { if (value != null && value.IsReadOnly) { this._nfi = value.NumberFormat; } else { this._nfi = null; } } } // Token: 0x17000BDB RID: 3035 // (get) Token: 0x06004009 RID: 16393 RVA: 0x000D8794 File Offset: 0x000D6994 private int IntegerDigits { get { return (this._decPointPos <= 0) ? 1 : this._decPointPos; } } // Token: 0x17000BDC RID: 3036 // (get) Token: 0x0600400A RID: 16394 RVA: 0x000D87B0 File Offset: 0x000D69B0 private int DecimalDigits { get { return (this._digitsLen <= this._decPointPos) ? 0 : (this._digitsLen - this._decPointPos); } } // Token: 0x17000BDD RID: 3037 // (get) Token: 0x0600400B RID: 16395 RVA: 0x000D87E4 File Offset: 0x000D69E4 private bool IsFloatingSource { get { return this._defPrecision == 15 || this._defPrecision == 7; } } // Token: 0x17000BDE RID: 3038 // (get) Token: 0x0600400C RID: 16396 RVA: 0x000D8800 File Offset: 0x000D6A00 private bool IsZero { get { return this._digitsLen == 0; } } // Token: 0x17000BDF RID: 3039 // (get) Token: 0x0600400D RID: 16397 RVA: 0x000D880C File Offset: 0x000D6A0C private bool IsZeroInteger { get { return this._digitsLen == 0 || this._decPointPos <= 0; } } // Token: 0x0600400E RID: 16398 RVA: 0x000D8828 File Offset: 0x000D6A28 private void RoundPos(int pos) { this.RoundBits(this._digitsLen - pos); } // Token: 0x0600400F RID: 16399 RVA: 0x000D883C File Offset: 0x000D6A3C private bool RoundDecimal(int decimals) { return this.RoundBits(this._digitsLen - this._decPointPos - decimals); } // Token: 0x06004010 RID: 16400 RVA: 0x000D8854 File Offset: 0x000D6A54 private bool RoundBits(int shift) { if (shift <= 0) { return false; } if (shift > this._digitsLen) { this._digitsLen = 0; this._decPointPos = 1; this._val1 = (this._val2 = (this._val3 = (this._val4 = 0U))); this._positive = true; return false; } shift += this._offset; this._digitsLen += this._offset; while (shift > 8) { this._val1 = this._val2; this._val2 = this._val3; this._val3 = this._val4; this._val4 = 0U; this._digitsLen -= 8; shift -= 8; } shift = shift - 1 << 2; uint num = this._val1 >> shift; uint num2 = num & 15U; this._val1 = (num ^ num2) << shift; bool flag = false; if (num2 >= 5U) { this._val1 |= 2576980377U >> 28 - shift; this.AddOneToDecHex(); int num3 = this.DecHexLen(); flag = num3 != this._digitsLen; this._decPointPos = this._decPointPos + num3 - this._digitsLen; this._digitsLen = num3; } this.RemoveTrailingZeros(); return flag; } // Token: 0x06004011 RID: 16401 RVA: 0x000D89A8 File Offset: 0x000D6BA8 private void RemoveTrailingZeros() { this._offset = this.CountTrailingZeros(); this._digitsLen -= this._offset; if (this._digitsLen == 0) { this._offset = 0; this._decPointPos = 1; this._positive = true; } } // Token: 0x06004012 RID: 16402 RVA: 0x000D89F4 File Offset: 0x000D6BF4 private void AddOneToDecHex() { if (this._val1 == 2576980377U) { this._val1 = 0U; if (this._val2 == 2576980377U) { this._val2 = 0U; if (this._val3 == 2576980377U) { this._val3 = 0U; this._val4 = NumberFormatter.AddOneToDecHex(this._val4); } else { this._val3 = NumberFormatter.AddOneToDecHex(this._val3); } } else { this._val2 = NumberFormatter.AddOneToDecHex(this._val2); } } else { this._val1 = NumberFormatter.AddOneToDecHex(this._val1); } } // Token: 0x06004013 RID: 16403 RVA: 0x000D8A9C File Offset: 0x000D6C9C private static uint AddOneToDecHex(uint val) { if ((val & 65535U) == 39321U) { if ((val & 16777215U) == 10066329U) { if ((val & 268435455U) == 161061273U) { return val + 107374183U; } return val + 6710887U; } else { if ((val & 1048575U) == 629145U) { return val + 419431U; } return val + 26215U; } } else if ((val & 255U) == 153U) { if ((val & 4095U) == 2457U) { return val + 1639U; } return val + 103U; } else { if ((val & 15U) == 9U) { return val + 7U; } return val + 1U; } } // Token: 0x06004014 RID: 16404 RVA: 0x000D8B50 File Offset: 0x000D6D50 private int CountTrailingZeros() { if (this._val1 != 0U) { return NumberFormatter.CountTrailingZeros(this._val1); } if (this._val2 != 0U) { return NumberFormatter.CountTrailingZeros(this._val2) + 8; } if (this._val3 != 0U) { return NumberFormatter.CountTrailingZeros(this._val3) + 16; } if (this._val4 != 0U) { return NumberFormatter.CountTrailingZeros(this._val4) + 24; } return this._digitsLen; } // Token: 0x06004015 RID: 16405 RVA: 0x000D8BC8 File Offset: 0x000D6DC8 private static int CountTrailingZeros(uint val) { if ((val & 65535U) == 0U) { if ((val & 16777215U) == 0U) { if ((val & 268435455U) == 0U) { return 7; } return 6; } else { if ((val & 1048575U) == 0U) { return 5; } return 4; } } else if ((val & 255U) == 0U) { if ((val & 4095U) == 0U) { return 3; } return 2; } else { if ((val & 15U) == 0U) { return 1; } return 0; } } // Token: 0x06004016 RID: 16406 RVA: 0x000D8C38 File Offset: 0x000D6E38 private static NumberFormatter GetInstance() { NumberFormatter numberFormatter = NumberFormatter.threadNumberFormatter; NumberFormatter.threadNumberFormatter = null; if (numberFormatter == null) { return new NumberFormatter(Thread.CurrentThread); } return numberFormatter; } // Token: 0x06004017 RID: 16407 RVA: 0x000D8C64 File Offset: 0x000D6E64 private void Release() { NumberFormatter.threadNumberFormatter = this; } // Token: 0x06004018 RID: 16408 RVA: 0x000D8C6C File Offset: 0x000D6E6C internal static void SetThreadCurrentCulture(CultureInfo culture) { if (NumberFormatter.threadNumberFormatter != null) { NumberFormatter.threadNumberFormatter.CurrentCulture = culture; } } // Token: 0x06004019 RID: 16409 RVA: 0x000D8C84 File Offset: 0x000D6E84 public static string NumberToString(string format, sbyte value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, (int)value, 3); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401A RID: 16410 RVA: 0x000D8CB4 File Offset: 0x000D6EB4 public static string NumberToString(string format, byte value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, (int)value, 3); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401B RID: 16411 RVA: 0x000D8CE0 File Offset: 0x000D6EE0 public static string NumberToString(string format, ushort value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, (int)value, 5); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401C RID: 16412 RVA: 0x000D8D0C File Offset: 0x000D6F0C public static string NumberToString(string format, short value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, (int)value, 5); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401D RID: 16413 RVA: 0x000D8D38 File Offset: 0x000D6F38 public static string NumberToString(string format, uint value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value, 10); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401E RID: 16414 RVA: 0x000D8D68 File Offset: 0x000D6F68 public static string NumberToString(string format, int value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value, 10); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x0600401F RID: 16415 RVA: 0x000D8D98 File Offset: 0x000D6F98 public static string NumberToString(string format, ulong value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x06004020 RID: 16416 RVA: 0x000D8DC4 File Offset: 0x000D6FC4 public static string NumberToString(string format, long value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value); string text = instance.IntegerToString(format, fp); instance.Release(); return text; } // Token: 0x06004021 RID: 16417 RVA: 0x000D8DF0 File Offset: 0x000D6FF0 public static string NumberToString(string format, float value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, (double)value, 7); NumberFormatInfo numberFormatInstance = instance.GetNumberFormatInstance(fp); string text; if (instance._NaN) { text = numberFormatInstance.NaNSymbol; } else if (instance._infinity) { if (instance._positive) { text = numberFormatInstance.PositiveInfinitySymbol; } else { text = numberFormatInstance.NegativeInfinitySymbol; } } else if (instance._specifier == 'R') { text = instance.FormatRoundtrip(value, numberFormatInstance); } else { text = instance.NumberToString(format, numberFormatInstance); } instance.Release(); return text; } // Token: 0x06004022 RID: 16418 RVA: 0x000D8E88 File Offset: 0x000D7088 public static string NumberToString(string format, double value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value, 15); NumberFormatInfo numberFormatInstance = instance.GetNumberFormatInstance(fp); string text; if (instance._NaN) { text = numberFormatInstance.NaNSymbol; } else if (instance._infinity) { if (instance._positive) { text = numberFormatInstance.PositiveInfinitySymbol; } else { text = numberFormatInstance.NegativeInfinitySymbol; } } else if (instance._specifier == 'R') { text = instance.FormatRoundtrip(value, numberFormatInstance); } else { text = instance.NumberToString(format, numberFormatInstance); } instance.Release(); return text; } // Token: 0x06004023 RID: 16419 RVA: 0x000D8F20 File Offset: 0x000D7120 public static string NumberToString(string format, decimal value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(format, value); string text = instance.NumberToString(format, instance.GetNumberFormatInstance(fp)); instance.Release(); return text; } // Token: 0x06004024 RID: 16420 RVA: 0x000D8F54 File Offset: 0x000D7154 public static string NumberToString(uint value, IFormatProvider fp) { if (value >= 100000000U) { return NumberFormatter.NumberToString(null, value, fp); } NumberFormatter instance = NumberFormatter.GetInstance(); string text = instance.FastIntegerToString((int)value, fp); instance.Release(); return text; } // Token: 0x06004025 RID: 16421 RVA: 0x000D8F8C File Offset: 0x000D718C public static string NumberToString(int value, IFormatProvider fp) { if (value >= 100000000 || value <= -100000000) { return NumberFormatter.NumberToString(null, value, fp); } NumberFormatter instance = NumberFormatter.GetInstance(); string text = instance.FastIntegerToString(value, fp); instance.Release(); return text; } // Token: 0x06004026 RID: 16422 RVA: 0x000D8FD0 File Offset: 0x000D71D0 public static string NumberToString(ulong value, IFormatProvider fp) { if (value >= 100000000UL) { return NumberFormatter.NumberToString(null, value, fp); } NumberFormatter instance = NumberFormatter.GetInstance(); string text = instance.FastIntegerToString((int)value, fp); instance.Release(); return text; } // Token: 0x06004027 RID: 16423 RVA: 0x000D900C File Offset: 0x000D720C public static string NumberToString(long value, IFormatProvider fp) { if (value >= 100000000L || value <= -100000000L) { return NumberFormatter.NumberToString(null, value, fp); } NumberFormatter instance = NumberFormatter.GetInstance(); string text = instance.FastIntegerToString((int)value, fp); instance.Release(); return text; } // Token: 0x06004028 RID: 16424 RVA: 0x000D9054 File Offset: 0x000D7254 public static string NumberToString(float value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); instance.Init(null, (double)value, 7); NumberFormatInfo numberFormatInstance = instance.GetNumberFormatInstance(fp); string text; if (instance._NaN) { text = numberFormatInstance.NaNSymbol; } else if (instance._infinity) { if (instance._positive) { text = numberFormatInstance.PositiveInfinitySymbol; } else { text = numberFormatInstance.NegativeInfinitySymbol; } } else { text = instance.FormatGeneral(-1, numberFormatInstance); } instance.Release(); return text; } // Token: 0x06004029 RID: 16425 RVA: 0x000D90D0 File Offset: 0x000D72D0 public static string NumberToString(double value, IFormatProvider fp) { NumberFormatter instance = NumberFormatter.GetInstance(); NumberFormatInfo numberFormatInstance = instance.GetNumberFormatInstance(fp); instance.Init(null, value, 15); string text; if (instance._NaN) { text = numberFormatInstance.NaNSymbol; } else if (instance._infinity) { if (instance._positive) { text = numberFormatInstance.PositiveInfinitySymbol; } else { text = numberFormatInstance.NegativeInfinitySymbol; } } else { text = instance.FormatGeneral(-1, numberFormatInstance); } instance.Release(); return text; } // Token: 0x0600402A RID: 16426 RVA: 0x000D914C File Offset: 0x000D734C private string FastIntegerToString(int value, IFormatProvider fp) { if (value < 0) { string negativeSign = this.GetNumberFormatInstance(fp).NegativeSign; this.ResetCharBuf(8 + negativeSign.Length); value = -value; this.Append(negativeSign); } else { this.ResetCharBuf(8); } if (value >= 10000) { int num = value / 10000; this.FastAppendDigits(num, false); this.FastAppendDigits(value - num * 10000, true); } else { this.FastAppendDigits(value, false); } return new string(this._cbuf, 0, this._ind); } // Token: 0x0600402B RID: 16427 RVA: 0x000D91DC File Offset: 0x000D73DC private string IntegerToString(string format, IFormatProvider fp) { NumberFormatInfo numberFormatInstance = this.GetNumberFormatInstance(fp); char specifier = this._specifier; switch (specifier) { case 'C': return this.FormatCurrency(this._precision, numberFormatInstance); case 'D': return this.FormatDecimal(this._precision, numberFormatInstance); case 'E': return this.FormatExponential(this._precision, numberFormatInstance); case 'F': return this.FormatFixedPoint(this._precision, numberFormatInstance); case 'G': if (this._precision <= 0) { return this.FormatDecimal(-1, numberFormatInstance); } return this.FormatGeneral(this._precision, numberFormatInstance); default: if (specifier == 'X') { return this.FormatHexadecimal(this._precision); } if (this._isCustomFormat) { return this.FormatCustom(format, numberFormatInstance); } throw new FormatException("The specified format '" + format + "' is invalid"); case 'N': return this.FormatNumber(this._precision, numberFormatInstance); case 'P': return this.FormatPercent(this._precision, numberFormatInstance); } } // Token: 0x0600402C RID: 16428 RVA: 0x000D92F4 File Offset: 0x000D74F4 private string NumberToString(string format, NumberFormatInfo nfi) { char specifier = this._specifier; switch (specifier) { case 'C': return this.FormatCurrency(this._precision, nfi); default: switch (specifier) { case 'N': return this.FormatNumber(this._precision, nfi); default: if (specifier != 'X') { } if (this._isCustomFormat) { return this.FormatCustom(format, nfi); } throw new FormatException("The specified format '" + format + "' is invalid"); case 'P': return this.FormatPercent(this._precision, nfi); } break; case 'E': return this.FormatExponential(this._precision, nfi); case 'F': return this.FormatFixedPoint(this._precision, nfi); case 'G': return this.FormatGeneral(this._precision, nfi); } } // Token: 0x0600402D RID: 16429 RVA: 0x000D93C4 File Offset: 0x000D75C4 public string FormatCurrency(int precision, NumberFormatInfo nfi) { precision = ((precision < 0) ? nfi.CurrencyDecimalDigits : precision); this.RoundDecimal(precision); this.ResetCharBuf(this.IntegerDigits * 2 + precision * 2 + 16); if (this._positive) { switch (nfi.CurrencyPositivePattern) { case 0: this.Append(nfi.CurrencySymbol); break; case 2: this.Append(nfi.CurrencySymbol); this.Append(' '); break; } } else { switch (nfi.CurrencyNegativePattern) { case 0: this.Append('('); this.Append(nfi.CurrencySymbol); break; case 1: this.Append(nfi.NegativeSign); this.Append(nfi.CurrencySymbol); break; case 2: this.Append(nfi.CurrencySymbol); this.Append(nfi.NegativeSign); break; case 3: this.Append(nfi.CurrencySymbol); break; case 4: this.Append('('); break; case 5: this.Append(nfi.NegativeSign); break; case 8: this.Append(nfi.NegativeSign); break; case 9: this.Append(nfi.NegativeSign); this.Append(nfi.CurrencySymbol); this.Append(' '); break; case 11: this.Append(nfi.CurrencySymbol); this.Append(' '); break; case 12: this.Append(nfi.CurrencySymbol); this.Append(' '); this.Append(nfi.NegativeSign); break; case 14: this.Append('('); this.Append(nfi.CurrencySymbol); this.Append(' '); break; case 15: this.Append('('); break; } } this.AppendIntegerStringWithGroupSeparator(nfi.RawCurrencyGroupSizes, nfi.CurrencyGroupSeparator); if (precision > 0) { this.Append(nfi.CurrencyDecimalSeparator); this.AppendDecimalString(precision); } if (this._positive) { switch (nfi.CurrencyPositivePattern) { case 1: this.Append(nfi.CurrencySymbol); break; case 3: this.Append(' '); this.Append(nfi.CurrencySymbol); break; } } else { switch (nfi.CurrencyNegativePattern) { case 0: this.Append(')'); break; case 3: this.Append(nfi.NegativeSign); break; case 4: this.Append(nfi.CurrencySymbol); this.Append(')'); break; case 5: this.Append(nfi.CurrencySymbol); break; case 6: this.Append(nfi.NegativeSign); this.Append(nfi.CurrencySymbol); break; case 7: this.Append(nfi.CurrencySymbol); this.Append(nfi.NegativeSign); break; case 8: this.Append(' '); this.Append(nfi.CurrencySymbol); break; case 10: this.Append(' '); this.Append(nfi.CurrencySymbol); this.Append(nfi.NegativeSign); break; case 11: this.Append(nfi.NegativeSign); break; case 13: this.Append(nfi.NegativeSign); this.Append(' '); this.Append(nfi.CurrencySymbol); break; case 14: this.Append(')'); break; case 15: this.Append(' '); this.Append(nfi.CurrencySymbol); this.Append(')'); break; } } return new string(this._cbuf, 0, this._ind); } // Token: 0x0600402E RID: 16430 RVA: 0x000D97E0 File Offset: 0x000D79E0 private string FormatDecimal(int precision, NumberFormatInfo nfi) { if (precision < this._digitsLen) { precision = this._digitsLen; } if (precision == 0) { return "0"; } this.ResetCharBuf(precision + 1); if (!this._positive) { this.Append(nfi.NegativeSign); } this.AppendDigits(0, precision); return new string(this._cbuf, 0, this._ind); } // Token: 0x0600402F RID: 16431 RVA: 0x000D9848 File Offset: 0x000D7A48 private unsafe string FormatHexadecimal(int precision) { int i = Math.Max(precision, this._decPointPos); char* ptr = ((!this._specifierIsUpper) ? NumberFormatter.DigitLowerTable : NumberFormatter.DigitUpperTable); this.ResetCharBuf(i); this._ind = i; ulong num = (ulong)this._val1 | ((ulong)this._val2 << 32); while (i > 0) { this._cbuf[--i] = ptr[(num & 15UL) * 2UL / 2UL]; num >>= 4; } return new string(this._cbuf, 0, this._ind); } // Token: 0x06004030 RID: 16432 RVA: 0x000D98D8 File Offset: 0x000D7AD8 public string FormatFixedPoint(int precision, NumberFormatInfo nfi) { if (precision == -1) { precision = nfi.NumberDecimalDigits; } this.RoundDecimal(precision); this.ResetCharBuf(this.IntegerDigits + precision + 2); if (!this._positive) { this.Append(nfi.NegativeSign); } this.AppendIntegerString(this.IntegerDigits); if (precision > 0) { this.Append(nfi.NumberDecimalSeparator); this.AppendDecimalString(precision); } return new string(this._cbuf, 0, this._ind); } // Token: 0x06004031 RID: 16433 RVA: 0x000D995C File Offset: 0x000D7B5C private string FormatRoundtrip(double origval, NumberFormatInfo nfi) { NumberFormatter clone = this.GetClone(); if (origval >= -1.79769313486231E+308 && origval <= 1.79769313486231E+308) { string text = this.FormatGeneral(this._defPrecision, nfi); if (origval == double.Parse(text, nfi)) { return text; } } return clone.FormatGeneral(this._defPrecision + 2, nfi); } // Token: 0x06004032 RID: 16434 RVA: 0x000D99BC File Offset: 0x000D7BBC private string FormatRoundtrip(float origval, NumberFormatInfo nfi) { NumberFormatter clone = this.GetClone(); string text = this.FormatGeneral(this._defPrecision, nfi); if (origval == float.Parse(text, nfi)) { return text; } return clone.FormatGeneral(this._defPrecision + 2, nfi); } // Token: 0x06004033 RID: 16435 RVA: 0x000D99FC File Offset: 0x000D7BFC private string FormatGeneral(int precision, NumberFormatInfo nfi) { bool flag; if (precision == -1) { flag = this.IsFloatingSource; precision = this._defPrecision; } else { flag = true; if (precision == 0) { precision = this._defPrecision; } this.RoundPos(precision); } int num = this._decPointPos; int digitsLen = this._digitsLen; int num2 = digitsLen - num; if ((num > precision || num <= -4) && flag) { return this.FormatExponential(digitsLen - 1, nfi, 2); } if (num2 < 0) { num2 = 0; } if (num < 0) { num = 0; } this.ResetCharBuf(num2 + num + 3); if (!this._positive) { this.Append(nfi.NegativeSign); } if (num == 0) { this.Append('0'); } else { this.AppendDigits(digitsLen - num, digitsLen); } if (num2 > 0) { this.Append(nfi.NumberDecimalSeparator); this.AppendDigits(0, num2); } return new string(this._cbuf, 0, this._ind); } // Token: 0x06004034 RID: 16436 RVA: 0x000D9AEC File Offset: 0x000D7CEC public string FormatNumber(int precision, NumberFormatInfo nfi) { precision = ((precision < 0) ? nfi.NumberDecimalDigits : precision); this.ResetCharBuf(this.IntegerDigits * 3 + precision); this.RoundDecimal(precision); if (!this._positive) { switch (nfi.NumberNegativePattern) { case 0: this.Append('('); break; case 1: this.Append(nfi.NegativeSign); break; case 2: this.Append(nfi.NegativeSign); this.Append(' '); break; } } this.AppendIntegerStringWithGroupSeparator(nfi.RawNumberGroupSizes, nfi.NumberGroupSeparator); if (precision > 0) { this.Append(nfi.NumberDecimalSeparator); this.AppendDecimalString(precision); } if (!this._positive) { switch (nfi.NumberNegativePattern) { case 0: this.Append(')'); break; case 3: this.Append(nfi.NegativeSign); break; case 4: this.Append(' '); this.Append(nfi.NegativeSign); break; } } return new string(this._cbuf, 0, this._ind); } // Token: 0x06004035 RID: 16437 RVA: 0x000D9C2C File Offset: 0x000D7E2C public string FormatPercent(int precision, NumberFormatInfo nfi) { precision = ((precision < 0) ? nfi.PercentDecimalDigits : precision); this.Multiply10(2); this.RoundDecimal(precision); this.ResetCharBuf(this.IntegerDigits * 2 + precision + 16); if (this._positive) { if (nfi.PercentPositivePattern == 2) { this.Append(nfi.PercentSymbol); } } else { switch (nfi.PercentNegativePattern) { case 0: this.Append(nfi.NegativeSign); break; case 1: this.Append(nfi.NegativeSign); break; case 2: this.Append(nfi.NegativeSign); this.Append(nfi.PercentSymbol); break; } } this.AppendIntegerStringWithGroupSeparator(nfi.RawPercentGroupSizes, nfi.PercentGroupSeparator); if (precision > 0) { this.Append(nfi.PercentDecimalSeparator); this.AppendDecimalString(precision); } if (this._positive) { int num = nfi.PercentPositivePattern; if (num != 0) { if (num == 1) { this.Append(nfi.PercentSymbol); } } else { this.Append(' '); this.Append(nfi.PercentSymbol); } } else { int num = nfi.PercentNegativePattern; if (num != 0) { if (num == 1) { this.Append(nfi.PercentSymbol); } } else { this.Append(' '); this.Append(nfi.PercentSymbol); } } return new string(this._cbuf, 0, this._ind); } // Token: 0x06004036 RID: 16438 RVA: 0x000D9DCC File Offset: 0x000D7FCC public string FormatExponential(int precision, NumberFormatInfo nfi) { if (precision == -1) { precision = 6; } this.RoundPos(precision + 1); return this.FormatExponential(precision, nfi, 3); } // Token: 0x06004037 RID: 16439 RVA: 0x000D9DEC File Offset: 0x000D7FEC private string FormatExponential(int precision, NumberFormatInfo nfi, int expDigits) { int decPointPos = this._decPointPos; int digitsLen = this._digitsLen; int num = decPointPos - 1; int num2 = (this._decPointPos = 1); this.ResetCharBuf(precision + 8); if (!this._positive) { this.Append(nfi.NegativeSign); } this.AppendOneDigit(digitsLen - 1); if (precision > 0) { this.Append(nfi.NumberDecimalSeparator); this.AppendDigits(digitsLen - precision - 1, digitsLen - this._decPointPos); } this.AppendExponent(nfi, num, expDigits); return new string(this._cbuf, 0, this._ind); } // Token: 0x06004038 RID: 16440 RVA: 0x000D9E80 File Offset: 0x000D8080 public string FormatCustom(string format, NumberFormatInfo nfi) { bool positive = this._positive; int num = 0; int num2 = 0; NumberFormatter.CustomInfo.GetActiveSection(format, ref positive, this.IsZero, ref num, ref num2); if (num2 == 0) { return (!this._positive) ? nfi.NegativeSign : string.Empty; } this._positive = positive; NumberFormatter.CustomInfo customInfo = NumberFormatter.CustomInfo.Parse(format, num, num2, nfi); StringBuilder stringBuilder = new StringBuilder(customInfo.IntegerDigits * 2); StringBuilder stringBuilder2 = new StringBuilder(customInfo.DecimalDigits * 2); StringBuilder stringBuilder3 = ((!customInfo.UseExponent) ? null : new StringBuilder(customInfo.ExponentDigits * 2)); int num3 = 0; if (customInfo.Percents > 0) { this.Multiply10(2 * customInfo.Percents); } if (customInfo.Permilles > 0) { this.Multiply10(3 * customInfo.Permilles); } if (customInfo.DividePlaces > 0) { this.Divide10(customInfo.DividePlaces); } bool flag = true; if (customInfo.UseExponent && (customInfo.DecimalDigits > 0 || customInfo.IntegerDigits > 0)) { if (!this.IsZero) { this.RoundPos(customInfo.DecimalDigits + customInfo.IntegerDigits); num3 -= this._decPointPos - customInfo.IntegerDigits; this._decPointPos = customInfo.IntegerDigits; } flag = num3 <= 0; NumberFormatter.AppendNonNegativeNumber(stringBuilder3, (num3 >= 0) ? num3 : (-num3)); } else { this.RoundDecimal(customInfo.DecimalDigits); } if (customInfo.IntegerDigits != 0 || !this.IsZeroInteger) { this.AppendIntegerString(this.IntegerDigits, stringBuilder); } this.AppendDecimalString(this.DecimalDigits, stringBuilder2); if (customInfo.UseExponent) { if (customInfo.DecimalDigits <= 0 && customInfo.IntegerDigits <= 0) { this._positive = true; } if (stringBuilder.Length < customInfo.IntegerDigits) { stringBuilder.Insert(0, "0", customInfo.IntegerDigits - stringBuilder.Length); } while (stringBuilder3.Length < customInfo.ExponentDigits - customInfo.ExponentTailSharpDigits) { stringBuilder3.Insert(0, '0'); } if (flag && !customInfo.ExponentNegativeSignOnly) { stringBuilder3.Insert(0, nfi.PositiveSign); } else if (!flag) { stringBuilder3.Insert(0, nfi.NegativeSign); } } else { if (stringBuilder.Length < customInfo.IntegerDigits - customInfo.IntegerHeadSharpDigits) { stringBuilder.Insert(0, "0", customInfo.IntegerDigits - customInfo.IntegerHeadSharpDigits - stringBuilder.Length); } if (customInfo.IntegerDigits == customInfo.IntegerHeadSharpDigits && NumberFormatter.IsZeroOnly(stringBuilder)) { stringBuilder.Remove(0, stringBuilder.Length); } } NumberFormatter.ZeroTrimEnd(stringBuilder2, true); while (stringBuilder2.Length < customInfo.DecimalDigits - customInfo.DecimalTailSharpDigits) { stringBuilder2.Append('0'); } if (stringBuilder2.Length > customInfo.DecimalDigits) { stringBuilder2.Remove(customInfo.DecimalDigits, stringBuilder2.Length - customInfo.DecimalDigits); } return customInfo.Format(format, num, num2, nfi, this._positive, stringBuilder, stringBuilder2, stringBuilder3); } // Token: 0x06004039 RID: 16441 RVA: 0x000DA1D4 File Offset: 0x000D83D4 private static void ZeroTrimEnd(StringBuilder sb, bool canEmpty) { int num = 0; int num2 = sb.Length - 1; while ((!canEmpty) ? (num2 > 0) : (num2 >= 0)) { if (sb[num2] != '0') { break; } num++; num2--; } if (num > 0) { sb.Remove(sb.Length - num, num); } } // Token: 0x0600403A RID: 16442 RVA: 0x000DA240 File Offset: 0x000D8440 private static bool IsZeroOnly(StringBuilder sb) { for (int i = 0; i < sb.Length; i++) { if (char.IsDigit(sb[i]) && sb[i] != '0') { return false; } } return true; } // Token: 0x0600403B RID: 16443 RVA: 0x000DA288 File Offset: 0x000D8488 private static void AppendNonNegativeNumber(StringBuilder sb, int v) { if (v < 0) { throw new ArgumentException(); } int num = NumberFormatter.ScaleOrder((long)v) - 1; do { int num2 = v / (int)NumberFormatter.GetTenPowerOf(num); sb.Append((char)(48 | num2)); v -= (int)NumberFormatter.GetTenPowerOf(num--) * num2; } while (num >= 0); } // Token: 0x0600403C RID: 16444 RVA: 0x000DA2DC File Offset: 0x000D84DC private void AppendIntegerString(int minLength, StringBuilder sb) { if (this._decPointPos <= 0) { sb.Append('0', minLength); return; } if (this._decPointPos < minLength) { sb.Append('0', minLength - this._decPointPos); } this.AppendDigits(this._digitsLen - this._decPointPos, this._digitsLen, sb); } // Token: 0x0600403D RID: 16445 RVA: 0x000DA338 File Offset: 0x000D8538 private void AppendIntegerString(int minLength) { if (this._decPointPos <= 0) { this.Append('0', minLength); return; } if (this._decPointPos < minLength) { this.Append('0', minLength - this._decPointPos); } this.AppendDigits(this._digitsLen - this._decPointPos, this._digitsLen); } // Token: 0x0600403E RID: 16446 RVA: 0x000DA390 File Offset: 0x000D8590 private void AppendDecimalString(int precision, StringBuilder sb) { this.AppendDigits(this._digitsLen - precision - this._decPointPos, this._digitsLen - this._decPointPos, sb); } // Token: 0x0600403F RID: 16447 RVA: 0x000DA3B8 File Offset: 0x000D85B8 private void AppendDecimalString(int precision) { this.AppendDigits(this._digitsLen - precision - this._decPointPos, this._digitsLen - this._decPointPos); } // Token: 0x06004040 RID: 16448 RVA: 0x000DA3E8 File Offset: 0x000D85E8 private void AppendIntegerStringWithGroupSeparator(int[] groups, string groupSeparator) { if (this.IsZeroInteger) { this.Append('0'); return; } int num = 0; int num2 = 0; for (int i = 0; i < groups.Length; i++) { num += groups[i]; if (num > this._decPointPos) { break; } num2 = i; } if (groups.Length > 0 && num > 0) { int num3 = groups[num2]; int num4 = ((this._decPointPos <= num) ? 0 : (this._decPointPos - num)); if (num3 == 0) { while (num2 >= 0 && groups[num2] == 0) { num2--; } num3 = ((num4 <= 0) ? groups[num2] : num4); } int num5; if (num4 == 0) { num5 = num3; } else { num2 += num4 / num3; num5 = num4 % num3; if (num5 == 0) { num5 = num3; } else { num2++; } } int num6 = 0; while (this._decPointPos - num6 > num5 && num5 != 0) { this.AppendDigits(this._digitsLen - num6 - num5, this._digitsLen - num6); num6 += num5; this.Append(groupSeparator); if (--num2 < groups.Length && num2 >= 0) { num3 = groups[num2]; } num5 = num3; } this.AppendDigits(this._digitsLen - this._decPointPos, this._digitsLen - num6); } else { this.AppendDigits(this._digitsLen - this._decPointPos, this._digitsLen); } } // Token: 0x06004041 RID: 16449 RVA: 0x000DA578 File Offset: 0x000D8778 private void AppendExponent(NumberFormatInfo nfi, int exponent, int minDigits) { if (this._specifierIsUpper || this._specifier == 'R') { this.Append('E'); } else { this.Append('e'); } if (exponent >= 0) { this.Append(nfi.PositiveSign); } else { this.Append(nfi.NegativeSign); exponent = -exponent; } if (exponent == 0) { this.Append('0', minDigits); } else if (exponent < 10) { this.Append('0', minDigits - 1); this.Append((char)(48 | exponent)); } else { uint num = NumberFormatter.FastToDecHex(exponent); if (exponent >= 100 || minDigits == 3) { this.Append((char)(48U | (num >> 8))); } this.Append((char)(48U | ((num >> 4) & 15U))); this.Append((char)(48U | (num & 15U))); } } // Token: 0x06004042 RID: 16450 RVA: 0x000DA654 File Offset: 0x000D8854 private void AppendOneDigit(int start) { if (this._ind == this._cbuf.Length) { this.Resize(this._ind + 10); } start += this._offset; uint num; if (start < 0) { num = 0U; } else if (start < 8) { num = this._val1; } else if (start < 16) { num = this._val2; } else if (start < 24) { num = this._val3; } else if (start < 32) { num = this._val4; } else { num = 0U; } num >>= (start & 7) << 2; this._cbuf[this._ind++] = (char)(48U | (num & 15U)); } // Token: 0x06004043 RID: 16451 RVA: 0x000DA718 File Offset: 0x000D8918 private unsafe void FastAppendDigits(int val, bool force) { int ind = this._ind; int num2; if (force || val >= 100) { int num = val * 5243 >> 19; num2 = NumberFormatter.DecHexDigits[num]; if (force || val >= 1000) { this._cbuf[ind++] = (char)(48 | (num2 >> 4)); } this._cbuf[ind++] = (char)(48 | (num2 & 15)); num2 = NumberFormatter.DecHexDigits[val - num * 100]; } else { num2 = NumberFormatter.DecHexDigits[val]; } if (force || val >= 10) { this._cbuf[ind++] = (char)(48 | (num2 >> 4)); } this._cbuf[ind++] = (char)(48 | (num2 & 15)); this._ind = ind; } // Token: 0x06004044 RID: 16452 RVA: 0x000DA7E4 File Offset: 0x000D89E4 private void AppendDigits(int start, int end) { if (start >= end) { return; } int num = this._ind + (end - start); if (num > this._cbuf.Length) { this.Resize(num + 10); } this._ind = num; end += this._offset; start += this._offset; int num2 = start + 8 - (start & 7); for (;;) { uint num3; if (num2 == 8) { num3 = this._val1; } else if (num2 == 16) { num3 = this._val2; } else if (num2 == 24) { num3 = this._val3; } else if (num2 == 32) { num3 = this._val4; } else { num3 = 0U; } num3 >>= (start & 7) << 2; if (num2 > end) { num2 = end; } this._cbuf[--num] = (char)(48U | (num3 & 15U)); switch (num2 - start) { case 1: goto IL_1C8; case 2: goto IL_1AB; case 3: goto IL_18E; case 4: goto IL_171; case 5: goto IL_154; case 6: goto IL_137; case 7: goto IL_11A; case 8: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_11A; } IL_1D5: start = num2; num2 += 8; continue; IL_1C8: if (num2 == end) { break; } goto IL_1D5; IL_1AB: this._cbuf[--num] = (char)(48U | ((num3 >> 4) & 15U)); goto IL_1C8; IL_18E: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_1AB; IL_171: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_18E; IL_154: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_171; IL_137: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_154; IL_11A: this._cbuf[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_137; } } // Token: 0x06004045 RID: 16453 RVA: 0x000DA9D4 File Offset: 0x000D8BD4 private void AppendDigits(int start, int end, StringBuilder sb) { if (start >= end) { return; } int num = sb.Length + (end - start); sb.Length = num; end += this._offset; start += this._offset; int num2 = start + 8 - (start & 7); for (;;) { uint num3; if (num2 == 8) { num3 = this._val1; } else if (num2 == 16) { num3 = this._val2; } else if (num2 == 24) { num3 = this._val3; } else if (num2 == 32) { num3 = this._val4; } else { num3 = 0U; } num3 >>= (start & 7) << 2; if (num2 > end) { num2 = end; } sb[--num] = (char)(48U | (num3 & 15U)); switch (num2 - start) { case 1: goto IL_1A8; case 2: goto IL_18C; case 3: goto IL_170; case 4: goto IL_154; case 5: goto IL_138; case 6: goto IL_11C; case 7: goto IL_100; case 8: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_100; } IL_1B5: start = num2; num2 += 8; continue; IL_1A8: if (num2 == end) { break; } goto IL_1B5; IL_18C: sb[--num] = (char)(48U | ((num3 >> 4) & 15U)); goto IL_1A8; IL_170: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_18C; IL_154: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_170; IL_138: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_154; IL_11C: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_138; IL_100: sb[--num] = (char)(48U | ((num3 >>= 4) & 15U)); goto IL_11C; } } // Token: 0x06004046 RID: 16454 RVA: 0x000DABA4 File Offset: 0x000D8DA4 private void Multiply10(int count) { if (count <= 0 || this._digitsLen == 0) { return; } this._decPointPos += count; } // Token: 0x06004047 RID: 16455 RVA: 0x000DABC8 File Offset: 0x000D8DC8 private void Divide10(int count) { if (count <= 0 || this._digitsLen == 0) { return; } this._decPointPos -= count; } // Token: 0x06004048 RID: 16456 RVA: 0x000DABEC File Offset: 0x000D8DEC private NumberFormatter GetClone() { return (NumberFormatter)base.MemberwiseClone(); } // Token: 0x04001950 RID: 6480 private const int DefaultExpPrecision = 6; // Token: 0x04001951 RID: 6481 private const int HundredMillion = 100000000; // Token: 0x04001952 RID: 6482 private const long SeventeenDigitsThreshold = 10000000000000000L; // Token: 0x04001953 RID: 6483 private const ulong ULongDivHundredMillion = 184467440737UL; // Token: 0x04001954 RID: 6484 private const ulong ULongModHundredMillion = 9551616UL; // Token: 0x04001955 RID: 6485 private const int DoubleBitsExponentShift = 52; // Token: 0x04001956 RID: 6486 private const int DoubleBitsExponentMask = 2047; // Token: 0x04001957 RID: 6487 private const long DoubleBitsMantissaMask = 4503599627370495L; // Token: 0x04001958 RID: 6488 private const int DecimalBitsScaleMask = 2031616; // Token: 0x04001959 RID: 6489 private const int SingleDefPrecision = 7; // Token: 0x0400195A RID: 6490 private const int DoubleDefPrecision = 15; // Token: 0x0400195B RID: 6491 private const int Int8DefPrecision = 3; // Token: 0x0400195C RID: 6492 private const int UInt8DefPrecision = 3; // Token: 0x0400195D RID: 6493 private const int Int16DefPrecision = 5; // Token: 0x0400195E RID: 6494 private const int UInt16DefPrecision = 5; // Token: 0x0400195F RID: 6495 private const int Int32DefPrecision = 10; // Token: 0x04001960 RID: 6496 private const int UInt32DefPrecision = 10; // Token: 0x04001961 RID: 6497 private const int Int64DefPrecision = 19; // Token: 0x04001962 RID: 6498 private const int UInt64DefPrecision = 20; // Token: 0x04001963 RID: 6499 private const int DecimalDefPrecision = 100; // Token: 0x04001964 RID: 6500 private const int TenPowersListLength = 19; // Token: 0x04001965 RID: 6501 private const double MinRoundtripVal = -1.79769313486231E+308; // Token: 0x04001966 RID: 6502 private const double MaxRoundtripVal = 1.79769313486231E+308; // Token: 0x04001967 RID: 6503 private unsafe static readonly ulong* MantissaBitsTable; // Token: 0x04001968 RID: 6504 private unsafe static readonly int* TensExponentTable; // Token: 0x04001969 RID: 6505 private unsafe static readonly char* DigitLowerTable; // Token: 0x0400196A RID: 6506 private unsafe static readonly char* DigitUpperTable; // Token: 0x0400196B RID: 6507 private unsafe static readonly long* TenPowersList; // Token: 0x0400196C RID: 6508 private unsafe static readonly int* DecHexDigits; // Token: 0x0400196D RID: 6509 private Thread _thread; // Token: 0x0400196E RID: 6510 private NumberFormatInfo _nfi; // Token: 0x0400196F RID: 6511 private bool _NaN; // Token: 0x04001970 RID: 6512 private bool _infinity; // Token: 0x04001971 RID: 6513 private bool _isCustomFormat; // Token: 0x04001972 RID: 6514 private bool _specifierIsUpper; // Token: 0x04001973 RID: 6515 private bool _positive; // Token: 0x04001974 RID: 6516 private char _specifier; // Token: 0x04001975 RID: 6517 private int _precision; // Token: 0x04001976 RID: 6518 private int _defPrecision; // Token: 0x04001977 RID: 6519 private int _digitsLen; // Token: 0x04001978 RID: 6520 private int _offset; // Token: 0x04001979 RID: 6521 private int _decPointPos; // Token: 0x0400197A RID: 6522 private uint _val1; // Token: 0x0400197B RID: 6523 private uint _val2; // Token: 0x0400197C RID: 6524 private uint _val3; // Token: 0x0400197D RID: 6525 private uint _val4; // Token: 0x0400197E RID: 6526 private char[] _cbuf; // Token: 0x0400197F RID: 6527 private int _ind; // Token: 0x04001980 RID: 6528 [ThreadStatic] private static NumberFormatter threadNumberFormatter; // Token: 0x02000699 RID: 1689 private class CustomInfo { // Token: 0x0600404A RID: 16458 RVA: 0x000DAC14 File Offset: 0x000D8E14 public static void GetActiveSection(string format, ref bool positive, bool zero, ref int offset, ref int length) { int[] array = new int[3]; int num = 0; int num2 = 0; char c = '\0'; for (int i = 0; i < format.Length; i++) { char c2 = format[i]; if (c2 == c || (c == '\0' && (c2 == '"' || c2 == '\''))) { if (c == '\0') { c = c2; } else { c = '\0'; } } else if (c == '\0' && format[i] == ';' && (i == 0 || format[i - 1] != '\\')) { array[num++] = i - num2; num2 = i + 1; if (num == 3) { break; } } } if (num == 0) { offset = 0; length = format.Length; return; } if (num == 1) { if (positive || zero) { offset = 0; length = array[0]; return; } if (array[0] + 1 < format.Length) { positive = true; offset = array[0] + 1; length = format.Length - offset; return; } offset = 0; length = array[0]; return; } else if (num == 2) { if (zero) { offset = array[0] + array[1] + 2; length = format.Length - offset; return; } if (positive) { offset = 0; length = array[0]; return; } if (array[1] > 0) { positive = true; offset = array[0] + 1; length = array[1]; return; } offset = 0; length = array[0]; return; } else { if (num != 3) { throw new ArgumentException(); } if (zero) { offset = array[0] + array[1] + 2; length = array[2]; return; } if (positive) { offset = 0; length = array[0]; return; } if (array[1] > 0) { positive = true; offset = array[0] + 1; length = array[1]; return; } offset = 0; length = array[0]; return; } } // Token: 0x0600404B RID: 16459 RVA: 0x000DADE8 File Offset: 0x000D8FE8 public static NumberFormatter.CustomInfo Parse(string format, int offset, int length, NumberFormatInfo nfi) { char c = '\0'; bool flag = true; bool flag2 = false; bool flag3 = false; bool flag4 = true; NumberFormatter.CustomInfo customInfo = new NumberFormatter.CustomInfo(); int num = 0; int num2 = offset; while (num2 - offset < length) { char c2 = format[num2]; if (c2 == c && c2 != '\0') { c = '\0'; } else if (c == '\0') { if (flag3 && c2 != '\0' && c2 != '0' && c2 != '#') { flag3 = false; flag = customInfo.DecimalPointPos < 0; flag2 = !flag; num2--; } else { char c3 = c2; switch (c3) { case '"': case '\'': if (c2 == '"' || c2 == '\'') { c = c2; } goto IL_311; case '#': if (flag4 && flag) { customInfo.IntegerHeadSharpDigits++; } else if (flag2) { customInfo.DecimalTailSharpDigits++; } else if (flag3) { customInfo.ExponentTailSharpDigits++; } break; default: switch (c3) { case ',': if (flag && customInfo.IntegerDigits > 0) { num++; } goto IL_311; default: if (c3 != 'E') { if (c3 == '\\') { num2++; goto IL_311; } if (c3 != 'e') { if (c3 != '‰') { goto IL_311; } customInfo.Permilles++; goto IL_311; } } if (customInfo.UseExponent) { goto IL_311; } customInfo.UseExponent = true; flag = false; flag2 = false; flag3 = true; if (num2 + 1 - offset < length) { char c4 = format[num2 + 1]; if (c4 == '+') { customInfo.ExponentNegativeSignOnly = false; } if (c4 == '+' || c4 == '-') { num2++; } else if (c4 != '0' && c4 != '#') { customInfo.UseExponent = false; if (customInfo.DecimalPointPos < 0) { flag = true; } } } goto IL_311; case '.': flag = false; flag2 = true; flag3 = false; if (customInfo.DecimalPointPos == -1) { customInfo.DecimalPointPos = num2; } goto IL_311; case '0': break; } break; case '%': customInfo.Percents++; goto IL_311; } if (c2 != '#') { flag4 = false; if (flag2) { customInfo.DecimalTailSharpDigits = 0; } else if (flag3) { customInfo.ExponentTailSharpDigits = 0; } } if (customInfo.IntegerHeadPos == -1) { customInfo.IntegerHeadPos = num2; } if (flag) { customInfo.IntegerDigits++; if (num > 0) { customInfo.UseGroup = true; } num = 0; } else if (flag2) { customInfo.DecimalDigits++; } else if (flag3) { customInfo.ExponentDigits++; } } } IL_311: num2++; } if (customInfo.ExponentDigits == 0) { customInfo.UseExponent = false; } else { customInfo.IntegerHeadSharpDigits = 0; } if (customInfo.DecimalDigits == 0) { customInfo.DecimalPointPos = -1; } customInfo.DividePlaces += num * 3; return customInfo; } // Token: 0x0600404C RID: 16460 RVA: 0x000DB160 File Offset: 0x000D9360 public string Format(string format, int offset, int length, NumberFormatInfo nfi, bool positive, StringBuilder sb_int, StringBuilder sb_dec, StringBuilder sb_exp) { StringBuilder stringBuilder = new StringBuilder(); char c = '\0'; bool flag = true; bool flag2 = false; int num = 0; int i = 0; int num2 = 0; int[] rawNumberGroupSizes = nfi.RawNumberGroupSizes; string numberGroupSeparator = nfi.NumberGroupSeparator; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; if (this.UseGroup && rawNumberGroupSizes.Length > 0) { num3 = sb_int.Length; for (int j = 0; j < rawNumberGroupSizes.Length; j++) { num4 += rawNumberGroupSizes[j]; if (num4 <= num3) { num5 = j; } } num7 = rawNumberGroupSizes[num5]; int num8 = ((num3 <= num4) ? 0 : (num3 - num4)); if (num7 == 0) { while (num5 >= 0 && rawNumberGroupSizes[num5] == 0) { num5--; } num7 = ((num8 <= 0) ? rawNumberGroupSizes[num5] : num8); } if (num8 == 0) { num6 = num7; } else { num5 += num8 / num7; num6 = num8 % num7; if (num6 == 0) { num6 = num7; } else { num5++; } } } else { this.UseGroup = false; } int num9 = offset; while (num9 - offset < length) { char c2 = format[num9]; if (c2 == c && c2 != '\0') { c = '\0'; } else if (c != '\0') { stringBuilder.Append(c2); } else { char c3 = c2; switch (c3) { case '"': case '\'': if (c2 == '"' || c2 == '\'') { c = c2; } goto IL_474; case '#': break; default: switch (c3) { case ',': goto IL_474; default: { if (c3 != 'E') { if (c3 == '\\') { num9++; if (num9 - offset < length) { stringBuilder.Append(format[num9]); } goto IL_474; } if (c3 != 'e') { if (c3 != '‰') { stringBuilder.Append(c2); goto IL_474; } stringBuilder.Append(nfi.PerMilleSymbol); goto IL_474; } } if (sb_exp == null || !this.UseExponent) { stringBuilder.Append(c2); goto IL_474; } bool flag3 = true; bool flag4 = false; int num10 = num9 + 1; while (num10 - offset < length) { if (format[num10] == '0') { flag4 = true; } else if (num10 != num9 + 1 || (format[num10] != '+' && format[num10] != '-')) { if (!flag4) { flag3 = false; } break; } num10++; } if (flag3) { num9 = num10 - 1; flag = this.DecimalPointPos < 0; flag2 = !flag; stringBuilder.Append(c2); stringBuilder.Append(sb_exp); sb_exp = null; } else { stringBuilder.Append(c2); } goto IL_474; } case '.': if (this.DecimalPointPos == num9) { if (this.DecimalDigits > 0) { while (i < sb_int.Length) { stringBuilder.Append(sb_int[i++]); } } if (sb_dec.Length > 0) { stringBuilder.Append(nfi.NumberDecimalSeparator); } } flag = false; flag2 = true; goto IL_474; case '0': break; } break; case '%': stringBuilder.Append(nfi.PercentSymbol); goto IL_474; } if (flag) { num++; if (this.IntegerDigits - num < sb_int.Length + i || c2 == '0') { while (this.IntegerDigits - num + i < sb_int.Length) { stringBuilder.Append(sb_int[i++]); if (this.UseGroup && --num3 > 0 && --num6 == 0) { stringBuilder.Append(numberGroupSeparator); if (--num5 < rawNumberGroupSizes.Length && num5 >= 0) { num7 = rawNumberGroupSizes[num5]; } num6 = num7; } } } } else if (flag2) { if (num2 < sb_dec.Length) { stringBuilder.Append(sb_dec[num2++]); } } else { stringBuilder.Append(c2); } } IL_474: num9++; } if (!positive) { stringBuilder.Insert(0, nfi.NegativeSign); } return stringBuilder.ToString(); } // Token: 0x04001981 RID: 6529 public bool UseGroup; // Token: 0x04001982 RID: 6530 public int DecimalDigits; // Token: 0x04001983 RID: 6531 public int DecimalPointPos = -1; // Token: 0x04001984 RID: 6532 public int DecimalTailSharpDigits; // Token: 0x04001985 RID: 6533 public int IntegerDigits; // Token: 0x04001986 RID: 6534 public int IntegerHeadSharpDigits; // Token: 0x04001987 RID: 6535 public int IntegerHeadPos; // Token: 0x04001988 RID: 6536 public bool UseExponent; // Token: 0x04001989 RID: 6537 public int ExponentDigits; // Token: 0x0400198A RID: 6538 public int ExponentTailSharpDigits; // Token: 0x0400198B RID: 6539 public bool ExponentNegativeSignOnly = true; // Token: 0x0400198C RID: 6540 public int DividePlaces; // Token: 0x0400198D RID: 6541 public int Percents; // Token: 0x0400198E RID: 6542 public int Permilles; } } }