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

◆ TryRunHalf()

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

Definition at line 866 of file Number.cs.

867 {
868 Half value2 = (Half.IsNegative(value) ? Half.Negate(value) : value);
869 DiyFp diyFp;
870 bool flag;
871 int length;
872 int decimalExponent;
873 if (requestedDigits == -1)
874 {
875 diyFp = DiyFp.CreateAndGetBoundaries(value2, out var mMinus, out var mPlus);
876 DiyFp w = diyFp.Normalize();
877 flag = TryRunShortest(in mMinus, in w, in mPlus, number.Digits, out length, out decimalExponent);
878 }
879 else
880 {
881 diyFp = new DiyFp(value2);
882 DiyFp w2 = diyFp.Normalize();
883 flag = TryRunCounted(in w2, requestedDigits, number.Digits, out length, out decimalExponent);
884 }
885 if (flag)
886 {
887 number.Scale = length + decimalExponent;
888 number.Digits[length] = 0;
889 number.DigitsCount = length;
890 }
891 return flag;
892 }
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.Half.IsNegative(), System.length, System.Half.Negate(), System.Number.DiyFp.Normalize(), System.Number.Grisu3.TryRunCounted(), System.Number.Grisu3.TryRunShortest(), and System.value.

Referenced by System.Number.FormatHalf().