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

◆ TryNegativeInt64ToDecStr()

static unsafe bool System.Number.TryNegativeInt64ToDecStr ( long input,
int digits,
string sNegative,
Span< char > destination,
out int charsWritten )
inlinestaticprivate

Definition at line 2510 of file Number.cs.

2511 {
2512 if (digits < 1)
2513 {
2514 digits = 1;
2515 }
2516 ulong value = (ulong)(-input);
2517 int num = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-input))) + sNegative.Length;
2518 if (num > destination.Length)
2519 {
2520 charsWritten = 0;
2521 return false;
2522 }
2523 charsWritten = num;
2524 fixed (char* ptr = &MemoryMarshal.GetReference(destination))
2525 {
2526 char* bufferEnd = ptr + num;
2527 while (High32(value) != 0)
2528 {
2529 bufferEnd = UInt32ToDecChars(bufferEnd, Int64DivMod1E9(ref value), 9);
2530 digits -= 9;
2531 }
2532 bufferEnd = UInt32ToDecChars(bufferEnd, Low32(value), digits);
2533 for (int num2 = sNegative.Length - 1; num2 >= 0; num2--)
2534 {
2535 *(--bufferEnd) = sNegative[num2];
2536 }
2537 }
2538 return true;
2539 }
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.destination, System.Number.High32(), System.input, System.Number.Int64DivMod1E9(), System.Number.Low32(), System.Math.Max(), System.Number.UInt32ToDecChars(), and System.value.

Referenced by System.Number.TryFormatInt64().