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

◆ TryRunDouble()

static bool System.Number.Grisu3.TryRunDouble ( double value,
int requestedDigits,
ref NumberBuffer number )
inlinestatic

Definition at line 838 of file Number.cs.

839 {
840 double value2 = (double.IsNegative(value) ? (0.0 - value) : value);
841 DiyFp diyFp;
842 bool flag;
843 int length;
844 int decimalExponent;
845 if (requestedDigits == -1)
846 {
847 diyFp = DiyFp.CreateAndGetBoundaries(value2, out var mMinus, out var mPlus);
848 DiyFp w = diyFp.Normalize();
849 flag = TryRunShortest(in mMinus, in w, in mPlus, number.Digits, out length, out decimalExponent);
850 }
851 else
852 {
853 diyFp = new DiyFp(value2);
854 DiyFp w2 = diyFp.Normalize();
855 flag = TryRunCounted(in w2, requestedDigits, number.Digits, out length, out decimalExponent);
856 }
857 if (flag)
858 {
859 number.Scale = length + decimalExponent;
860 number.Digits[length] = 0;
861 number.DigitsCount = length;
862 }
863 return flag;
864 }
static bool TryRunShortest(in DiyFp boundaryMinus, in DiyFp w, in DiyFp boundaryPlus, Span< byte > buffer, out int length, out int decimalExponent)
Definition Number.cs:935
static bool TryRunCounted(in DiyFp w, int requestedDigits, Span< byte > buffer, out int length, out int decimalExponent)
Definition Number.cs:922

References System.Number.DiyFp.CreateAndGetBoundaries(), System.length, System.Number.DiyFp.Normalize(), System.Number.Grisu3.TryRunCounted(), System.Number.Grisu3.TryRunShortest(), and System.value.

Referenced by System.Number.FormatDouble().