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

◆ TryDigitGenShortest()

static bool System.Number.Grisu3.TryDigitGenShortest ( in DiyFp low,
in DiyFp w,
in DiyFp high,
Span< byte > buffer,
out int length,
out int kappa )
inlinestaticprivate

Definition at line 1017 of file Number.cs.

1018 {
1019 ulong num = 1uL;
1020 DiyFp other = new DiyFp(low.f - num, low.e);
1021 DiyFp diyFp = new DiyFp(high.f + num, high.e);
1022 DiyFp diyFp2 = diyFp.Subtract(in other);
1023 DiyFp diyFp3 = new DiyFp((ulong)(1L << -w.e), w.e);
1024 uint num2 = (uint)(diyFp.f >> -diyFp3.e);
1025 ulong num3 = diyFp.f & (diyFp3.f - 1);
1026 uint num4 = BiggestPowerTen(num2, 64 - -diyFp3.e, out kappa);
1027 length = 0;
1028 while (kappa > 0)
1029 {
1030 uint num5;
1031 (num5, num2) = Math.DivRem(num2, num4);
1032 buffer[length] = (byte)(48 + num5);
1033 length++;
1034 kappa--;
1035 ulong num6 = ((ulong)num2 << -diyFp3.e) + num3;
1036 if (num6 < diyFp2.f)
1037 {
1038 return TryRoundWeedShortest(buffer, length, diyFp.Subtract(in w).f, diyFp2.f, num6, (ulong)num4 << -diyFp3.e, num);
1039 }
1040 num4 /= 10;
1041 }
1042 do
1043 {
1044 num3 *= 10;
1045 num *= 10;
1046 diyFp2 = new DiyFp(diyFp2.f * 10, diyFp2.e);
1047 uint num7 = (uint)(num3 >> -diyFp3.e);
1048 buffer[length] = (byte)(48 + num7);
1049 length++;
1050 kappa--;
1051 num3 &= diyFp3.f - 1;
1052 }
1053 while (num3 >= diyFp2.f);
1054 return TryRoundWeedShortest(buffer, length, diyFp.Subtract(in w).f * num, diyFp2.f, num3, diyFp3.f, num);
1055 }
static bool TryRoundWeedShortest(Span< byte > buffer, int length, ulong distanceTooHighW, ulong unsafeInterval, ulong rest, ulong tenKappa, ulong unit)
Definition Number.cs:1095
static uint BiggestPowerTen(uint number, int numberBits, out int exponentPlusOne)
Definition Number.cs:950

References System.Number.Grisu3.BiggestPowerTen(), System.buffer, System.Math.DivRem(), System.Number.DiyFp.e, System.Number.DiyFp.f, System.L, System.length, System.other, System.Number.DiyFp.Subtract(), and System.Number.Grisu3.TryRoundWeedShortest().

Referenced by System.Number.Grisu3.TryRunShortest().