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

◆ TryRunSingle()

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

Definition at line 894 of file Number.cs.

895 {
896 float value2 = (float.IsNegative(value) ? (0f - value) : value);
897 DiyFp diyFp;
898 bool flag;
899 int length;
900 int decimalExponent;
901 if (requestedDigits == -1)
902 {
903 diyFp = DiyFp.CreateAndGetBoundaries(value2, out var mMinus, out var mPlus);
904 DiyFp w = diyFp.Normalize();
905 flag = TryRunShortest(in mMinus, in w, in mPlus, number.Digits, out length, out decimalExponent);
906 }
907 else
908 {
909 diyFp = new DiyFp(value2);
910 DiyFp w2 = diyFp.Normalize();
911 flag = TryRunCounted(in w2, requestedDigits, number.Digits, out length, out decimalExponent);
912 }
913 if (flag)
914 {
915 number.Scale = length + decimalExponent;
916 number.Digits[length] = 0;
917 number.DigitsCount = length;
918 }
919 return flag;
920 }
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.FormatSingle().