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

◆ TryFormatDecimalE()

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

Definition at line 426 of file Utf8Formatter.cs.

427 {
428 int scale = number.Scale;
429 ReadOnlySpan<byte> readOnlySpan = number.Digits;
430 int num = (number.IsNegative ? 1 : 0) + 1 + ((precision != 0) ? (precision + 1) : 0) + 2 + 3;
431 if (destination.Length < num)
432 {
433 bytesWritten = 0;
434 return false;
435 }
436 int num2 = 0;
437 int num3 = 0;
438 if (number.IsNegative)
439 {
440 destination[num2++] = 45;
441 }
442 byte b = readOnlySpan[num3];
443 int num4;
444 if (b == 0)
445 {
446 destination[num2++] = 48;
447 num4 = 0;
448 }
449 else
450 {
451 destination[num2++] = b;
452 num3++;
453 num4 = scale - 1;
454 }
455 if (precision > 0)
456 {
457 destination[num2++] = 46;
458 for (int i = 0; i < precision; i++)
459 {
460 byte b2 = readOnlySpan[num3];
461 if (b2 == 0)
462 {
463 while (i++ < precision)
464 {
465 destination[num2++] = 48;
466 }
467 break;
468 }
469 destination[num2++] = b2;
470 num3++;
471 }
472 }
473 destination[num2++] = exponentSymbol;
474 if (num4 >= 0)
475 {
476 destination[num2++] = 43;
477 }
478 else
479 {
480 destination[num2++] = 45;
481 num4 = -num4;
482 }
483 destination[num2++] = 48;
484 destination[num2++] = (byte)(num4 / 10 + 48);
485 destination[num2++] = (byte)(num4 % 10 + 48);
486 bytesWritten = num;
487 return true;
488 }

References System.destination.

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