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

◆ NegativeInt64ToDecStr()

static unsafe string System.Number.NegativeInt64ToDecStr ( long input,
int digits,
string sNegative )
inlinestaticprivate

Definition at line 2484 of file Number.cs.

2485 {
2486 if (digits < 1)
2487 {
2488 digits = 1;
2489 }
2490 ulong value = (ulong)(-input);
2491 int num = Math.Max(digits, FormattingHelpers.CountDigits(value)) + sNegative.Length;
2492 string text = string.FastAllocateString(num);
2493 fixed (char* ptr = text)
2494 {
2495 char* bufferEnd = ptr + num;
2496 while (High32(value) != 0)
2497 {
2498 bufferEnd = UInt32ToDecChars(bufferEnd, Int64DivMod1E9(ref value), 9);
2499 digits -= 9;
2500 }
2501 bufferEnd = UInt32ToDecChars(bufferEnd, Low32(value), digits);
2502 for (int num2 = sNegative.Length - 1; num2 >= 0; num2--)
2503 {
2504 *(--bufferEnd) = sNegative[num2];
2505 }
2506 }
2507 return text;
2508 }
static uint High32(ulong value)
Definition Number.cs:3498
static uint Int64DivMod1E9(ref ulong value)
Definition Number.cs:3503
static uint Low32(ulong value)
Definition Number.cs:3493
static unsafe byte * UInt32ToDecChars(byte *bufferEnd, uint value, int digits)
Definition Number.cs:2360

References System.Buffers.Text.FormattingHelpers.CountDigits(), System.Number.High32(), System.input, System.Number.Int64DivMod1E9(), System.Number.Low32(), System.Math.Max(), System.text, System.Number.UInt32ToDecChars(), and System.value.

Referenced by System.Number.FormatInt64(), and System.Number.Int64ToDecStr().