378 {
380 {
382 }
384 {
385 case 'G':
386 case 'g':
387 {
388 if (
format.Precision !=
byte.MaxValue)
389 {
390 throw new NotSupportedException(SR.Argument_GWithPrecisionNotSupported);
391 }
392 byte* digits3 = stackalloc byte[31];
393 Number.NumberBuffer number3 =
new Number.NumberBuffer(
Number.NumberBufferKind.Decimal, digits3, 31);
395 if (number3.Digits[0] == 0)
396 {
397 number3.IsNegative = false;
398 }
400 }
401 case 'F':
402 case 'f':
403 {
404 byte* digits2 = stackalloc byte[31];
405 Number.NumberBuffer number2 =
new Number.NumberBuffer(
Number.NumberBufferKind.Decimal, digits2, 31);
407 byte b2 = (byte)((
format.Precision ==
byte.MaxValue) ? 2 :
format.Precision);
408 Number.RoundNumber(ref number2, number2.Scale + b2, isCorrectlyRounded: false);
410 }
411 case 'E':
412 case 'e':
413 {
414 byte* digits = stackalloc byte[31];
415 Number.NumberBuffer number =
new Number.NumberBuffer(
Number.NumberBufferKind.Decimal, digits, 31);
417 byte b = (byte)((
format.Precision ==
byte.MaxValue) ? 6 :
format.Precision);
418 Number.RoundNumber(ref number, b + 1, isCorrectlyRounded: false);
420 }
421 default:
422 return FormattingHelpers.TryFormatThrowFormatException(out bytesWritten);
423 }
424 }
static bool TryFormatDecimalE(ref Number.NumberBuffer number, Span< byte > destination, out int bytesWritten, byte precision, byte exponentSymbol)
static bool TryFormatDecimalG(ref Number.NumberBuffer number, Span< byte > destination, out int bytesWritten)
static bool TryFormatDecimalF(ref Number.NumberBuffer number, Span< byte > destination, out int bytesWritten, byte precision)