Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FormatDouble() [2/2]

static unsafe string System.Number.FormatDouble ( ref ValueStringBuilder sb,
double value,
ReadOnlySpan< char > format,
NumberFormatInfo info )
inlinestaticprivate

Definition at line 1696 of file Number.cs.

1697 {
1698 if (!double.IsFinite(value))
1699 {
1700 if (double.IsNaN(value))
1701 {
1702 return info.NaNSymbol;
1703 }
1704 if (!double.IsNegative(value))
1705 {
1706 return info.PositiveInfinitySymbol;
1707 }
1708 return info.NegativeInfinitySymbol;
1709 }
1710 int digits;
1711 char c = ParseFormatSpecifier(format, out digits);
1712 byte* digits2 = stackalloc byte[769];
1713 if (c == '\0')
1714 {
1715 digits = 15;
1716 }
1717 NumberBuffer number = new NumberBuffer(NumberBufferKind.FloatingPoint, digits2, 769);
1718 number.IsNegative = double.IsNegative(value);
1719 bool isSignificantDigits;
1720 int nMaxDigits = GetFloatingPointMaxDigitsAndPrecision(c, ref digits, info, out isSignificantDigits);
1721 if (value != 0.0 && (!isSignificantDigits || !Grisu3.TryRunDouble(value, digits, ref number)))
1722 {
1723 Dragon4Double(value, digits, isSignificantDigits, ref number);
1724 }
1725 if (c != 0)
1726 {
1727 if (digits == -1)
1728 {
1729 nMaxDigits = Math.Max(number.DigitsCount, 17);
1730 }
1731 NumberToString(ref sb, ref number, c, nMaxDigits, info);
1732 }
1733 else
1734 {
1735 NumberToStringFormat(ref sb, ref number, format, info);
1736 }
1737 return null;
1738 }
static char ParseFormatSpecifier(ReadOnlySpan< char > format, out int digits)
Definition Number.cs:2657
static unsafe void NumberToStringFormat(ref ValueStringBuilder sb, ref NumberBuffer number, ReadOnlySpan< char > format, NumberFormatInfo info)
Definition Number.cs:2817
static void NumberToString(ref ValueStringBuilder sb, ref NumberBuffer number, char format, int nMaxDigits, NumberFormatInfo info)
Definition Number.cs:2715
static void Dragon4Double(double value, int cutoffNumber, bool isSignificantDigits, ref NumberBuffer number)
Definition Number.cs:1266
static int GetFloatingPointMaxDigitsAndPrecision(char fmt, ref int precision, NumberFormatInfo info, out bool isSignificantDigits)
Definition Number.cs:1631

References System.Number.NumberBuffer.DigitsCount, System.Number.Dragon4Double(), System.format, System.Number.GetFloatingPointMaxDigitsAndPrecision(), System.info, System.Math.Max(), System.Number.NumberToString(), System.Number.NumberToStringFormat(), System.Number.ParseFormatSpecifier(), System.Number.Grisu3.TryRunDouble(), and System.value.