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

◆ TryUInt32ToDecStr()

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

Definition at line 2420 of file Number.cs.

2421 {
2422 int num = Math.Max(digits, FormattingHelpers.CountDigits(value));
2423 if (num > destination.Length)
2424 {
2425 charsWritten = 0;
2426 return false;
2427 }
2428 charsWritten = num;
2429 fixed (char* ptr = &MemoryMarshal.GetReference(destination))
2430 {
2431 char* ptr2 = ptr + num;
2432 if (digits <= 1)
2433 {
2434 do
2435 {
2436 uint num2;
2437 (value, num2) = Math.DivRem(value, 10u);
2438 *(--ptr2) = (char)(num2 + 48);
2439 }
2440 while (value != 0);
2441 }
2442 else
2443 {
2444 ptr2 = UInt32ToDecChars(ptr2, value, digits);
2445 }
2446 }
2447 return true;
2448 }
static unsafe byte * UInt32ToDecChars(byte *bufferEnd, uint value, int digits)
Definition Number.cs:2360

References System.Buffers.Text.FormattingHelpers.CountDigits(), System.destination, System.Math.DivRem(), System.Math.Max(), System.Number.UInt32ToDecChars(), and System.value.

Referenced by System.Number.TryFormatInt32(), and System.Number.TryFormatUInt32().