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

◆ TryFormatDecimalG()

static bool System.Buffers.Text.Utf8Formatter.TryFormatDecimalG ( ref Number::NumberBuffer number,
Span< byte > destination,
out int bytesWritten )
inlinestaticprivate

Definition at line 559 of file Utf8Formatter.cs.

560 {
561 int scale = number.Scale;
562 ReadOnlySpan<byte> readOnlySpan = number.Digits;
563 int digitsCount = number.DigitsCount;
564 bool flag = scale < digitsCount;
565 int num;
566 if (flag)
567 {
568 num = digitsCount + 1;
569 if (scale <= 0)
570 {
571 num += 1 + -scale;
572 }
573 }
574 else
575 {
576 num = ((scale <= 0) ? 1 : scale);
577 }
578 if (number.IsNegative)
579 {
580 num++;
581 }
582 if (destination.Length < num)
583 {
584 bytesWritten = 0;
585 return false;
586 }
587 int i = 0;
588 int num2 = 0;
589 if (number.IsNegative)
590 {
591 destination[num2++] = 45;
592 }
593 if (scale <= 0)
594 {
595 destination[num2++] = 48;
596 }
597 else
598 {
599 for (; i < scale; i++)
600 {
601 byte b = readOnlySpan[i];
602 if (b == 0)
603 {
604 int num3 = scale - i;
605 for (int j = 0; j < num3; j++)
606 {
607 destination[num2++] = 48;
608 }
609 break;
610 }
611 destination[num2++] = b;
612 }
613 }
614 if (flag)
615 {
616 destination[num2++] = 46;
617 if (scale < 0)
618 {
619 int num4 = -scale;
620 for (int k = 0; k < num4; k++)
621 {
622 destination[num2++] = 48;
623 }
624 }
625 byte b2;
626 while ((b2 = readOnlySpan[i++]) != 0)
627 {
628 destination[num2++] = b2;
629 }
630 }
631 bytesWritten = num;
632 return true;
633 }

References System.destination.

Referenced by System.Buffers.Text.Utf8Formatter.TryFormat().