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

◆ TryUInt64ToDecStr()

static unsafe bool System.Number.TryUInt64ToDecStr ( ulong value,
int digits,
Span< char > destination,
out int charsWritten )
inlinestaticprivate

Definition at line 2631 of file Number.cs.

2632 {
2633 if (digits < 1)
2634 {
2635 digits = 1;
2636 }
2637 int num = Math.Max(digits, FormattingHelpers.CountDigits(value));
2638 if (num > destination.Length)
2639 {
2640 charsWritten = 0;
2641 return false;
2642 }
2643 charsWritten = num;
2644 fixed (char* ptr = &MemoryMarshal.GetReference(destination))
2645 {
2646 char* bufferEnd = ptr + num;
2647 while (High32(value) != 0)
2648 {
2649 bufferEnd = UInt32ToDecChars(bufferEnd, Int64DivMod1E9(ref value), 9);
2650 digits -= 9;
2651 }
2652 bufferEnd = UInt32ToDecChars(bufferEnd, Low32(value), digits);
2653 }
2654 return true;
2655 }
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.Number.Int64DivMod1E9(), System.Number.Low32(), System.Math.Max(), System.Number.UInt32ToDecChars(), and System.value.

Referenced by System.Number.TryFormatInt64(), and System.Number.TryFormatUInt64().