28 "($#)",
"-$#",
"$-#",
"$#-",
"(#$)",
"-#$",
"#-$",
"#$-",
"-# $",
"-$ #",
29 "# $-",
"$ #-",
"$ -#",
"#- $",
"($ #)",
"(# $)",
"$- #"
36 "-# %",
"-#%",
"-%#",
"%-#",
"%#-",
"#-%",
"#%-",
"-% #",
"# %-",
"% #-",
40 private static readonly
string[]
s_negNumberFormats =
new string[5] {
"(#)",
"-#",
"- #",
"#-",
"# -" };
57 fixed (
char* str2 =
str)
71 char c = ((p < pEnd) ? (*p) :
'\0');
72 if (c != *
str && (*
str !=
'\u00a0' || c !=
' '))
89 string negativeSign =
info.NegativeSign;
90 bool flag = negativeSign.Length == 1;
95 switch (negativeSign[0])
116 private unsafe
static char*
MatchNegativeSignChars(
char* p,
char* pEnd,
string negativeSign,
bool allowHyphenDuringParsing)
118 char* ptr =
MatchChars(p, pEnd, negativeSign);
119 if (ptr ==
null && allowHyphenDuringParsing && p < pEnd && *p ==
'-')
148 bool flag2 = sb !=
null;
149 int num2 = (flag2 ? int.MaxValue : 32);
151 char c = ((ptr < strEnd) ? (*ptr) :
'\0');
152 char* digits = number.digits;
179 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
186 if ((c >=
'0' && c <=
'9') || ((
options &
NumberStyles.AllowHexSpecifier) != 0 && ((c >=
'a' && c <=
'f') || (c >=
'A' && c <=
'F'))))
189 if (c !=
'0' || ((uint)num & 8u) != 0 || (flag2 && (
options &
NumberStyles.AllowHexSpecifier) != 0))
201 if (c !=
'0' || parseDecimal)
206 if ((num & 0x10) == 0)
212 else if (((uint)num & 0x10u) != 0)
230 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
233 number.precision = num4;
242 if (((uint)num & 4u) != 0)
247 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
251 c = (((ptr = ptr2) < strEnd) ? (*ptr) :
'\0');
255 c = (((ptr = ptr2) < strEnd) ? (*ptr) :
'\0');
258 if (c >=
'0' && c <=
'9')
263 num5 = num5 * 10 + (c - 48);
264 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
268 while (c >=
'0' && c <=
'9')
270 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
274 while (c >=
'0' && c <=
'9');
279 number.scale += num5;
284 c = ((ptr < strEnd) ? (*ptr) :
'\0');
297 else if (c ==
')' && ((uint)num & 2u) != 0)
311 c = ((++ptr < strEnd) ? (*ptr) :
'\0');
321 if ((num & 0x10) == 0)
336 for (
int i =
index; i <
s.Length; i++)
361 while (--digits >= 0 ||
value != 0)
374 if ((uint)(c - 65) <= 25u || (uint)(c - 97) <= 25u)
390 else if (
format.Length == 3)
392 int num2 =
format[1] - 48;
393 int num3 =
format[2] - 48;
394 if ((uint)num2 < 10u && (uint)num3 < 10u)
396 digits = num2 * 10 + num3;
402 while (num5 <
format.Length && (uint)(
format[num5] - 48) < 10u)
404 int num6 = num4 * 10 +
format[num5++] - 48;
419 if (
format.Length != 0 && c != 0)
433 num = ((nMaxDigits >= 0) ? nMaxDigits :
info.CurrencyDecimalDigits);
436 nMaxDigits =
info.CurrencyDecimalDigits;
438 RoundNumber(ref number, number.scale + nMaxDigits);
445 nMaxDigits = (num =
info.NumberDecimalDigits);
451 RoundNumber(ref number, number.scale + nMaxDigits);
454 sb.Append(
info.NegativeSign);
456 FormatFixed(ref sb, ref number, num, nMaxDigits,
info,
null,
info.NumberDecimalSeparator,
null);
462 nMaxDigits = (num =
info.NumberDecimalDigits);
468 RoundNumber(ref number, number.scale + nMaxDigits);
475 nMaxDigits = (num = 6);
485 sb.Append(
info.NegativeSign);
495 if (isDecimal && nMaxDigits == -1)
497 nMaxDigits = (num = 29);
502 nMaxDigits = (num = number.precision);
513 else if (isDecimal && *number.digits ==
'\0')
519 sb.Append(
info.NegativeSign);
528 nMaxDigits = (num =
info.PercentDecimalDigits);
535 RoundNumber(ref number, number.scale + nMaxDigits);
547 foreach (
char c
in text2)
552 FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits,
info,
info.CurrencyGroupSizes,
info.CurrencyDecimalSeparator,
info.CurrencyGroupSeparator);
555 sb.Append(
info.NegativeSign);
558 sb.Append(
info.CurrencySymbol);
569 int scale = number.scale;
570 char* ptr = number.digits;
574 if (groupDigits !=
null)
577 int num2 = groupDigits[num];
578 int num3 = groupDigits.Length;
584 while (scale > num2 && groupDigits[num] != 0)
591 num2 += groupDigits[num];
592 if (num2 < 0 || num4 < 0)
597 num5 = ((num2 != 0) ? groupDigits[0] : 0);
599 char* ptr2 = stackalloc
char[num4];
603 char* ptr3 = ptr2 + num4 - 1;
604 for (
int num8 = scale - 1; num8 >= 0; num8--)
606 *(ptr3--) = ((num8 < num7) ? ptr[num8] :
'0');
610 if (num6 == num5 && num8 != 0)
612 for (
int num9 =
length2 - 1; num9 >= 0; num9--)
614 *(ptr3--) = sGroup[num9];
619 num5 = groupDigits[num];
625 sb.Append(ptr2, num4);
631 sb.Append(ptr, num10);
635 sb.Append(
'0', scale -
length);
646 if (scale < 0 && nMaxDigits > 0)
648 int num11 =
Math.
Min(-scale, nMaxDigits);
649 sb.Append(
'0', num11);
653 while (nMaxDigits > 0)
655 sb.Append((*ptr != 0) ? (*(ptr++)) :
'0');
665 foreach (
char c
in text2)
670 FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits,
info,
info.NumberGroupSizes,
info.NumberDecimalSeparator,
info.NumberGroupSeparator);
673 sb.Append(
info.NegativeSign);
684 char* digits = number.digits;
685 sb.Append((*digits != 0) ? (*(digits++)) :
'0');
688 sb.Append(
info.NumberDecimalSeparator);
690 while (--nMaxDigits > 0)
692 sb.Append((*digits != 0) ? (*(digits++)) :
'0');
694 int value = ((*number.digits != 0) ? (number.scale - 1) : 0);
703 sb.Append(
info.NegativeSign);
706 else if (positiveSign)
708 sb.Append(
info.PositiveSign);
710 char* ptr = stackalloc
char[11];
713 int num = 10 -
index;
716 sb.Append(ptr[
index++]);
722 int i = number.scale;
724 if (!bSuppressScientific && (i > nMaxDigits || i < -3))
729 char* digits = number.digits;
734 sb.Append((*digits != 0) ? (*(digits++)) :
'0');
742 if (*digits != 0 || i < 0)
744 sb.Append(
info.NumberDecimalSeparator);
751 sb.Append(*(digits++));
764 foreach (
char c
in text2)
769 FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits,
info,
info.PercentGroupSizes,
info.PercentDecimalSeparator,
info.PercentGroupSeparator);
772 sb.Append(
info.NegativeSign);
775 sb.Append(
info.PercentSymbol);
786 char* digits = number.digits;
788 for (i = 0; i < pos && digits[i] != 0; i++)
791 if (i == pos && digits[i] >=
'5')
793 while (i > 0 && digits[i - 1] ==
'9')
799 char* num = digits + (i - 1);
800 *num = (char)(*num + 1);
811 while (i > 0 && digits[i - 1] ==
'0')
840 char c2 = (c = ptr[num++]);
859 if (num <
format.Length && ptr[num] != 0)
869 if (num >=
format.Length || ptr[num] ==
'\0' || ptr[num] ==
';')
877 while (num <
format.Length && ptr[num] != 0 && ptr[num++] != c)
888 char* digits = number.digits;
911 while (num9 <
format.Length && (c = ptr[num9++]) != 0)
921 if (num5 ==
int.MaxValue)
935 if (num3 <= 0 || num4 >= 0)
959 while (num9 <
format.Length && ptr[num9] != 0 && ptr[num9++] != c)
964 if (num9 <
format.Length && ptr[num9] != 0)
971 if ((num9 <
format.Length && ptr[num9] ==
'0') || (num9 + 1 <
format.Length && (ptr[num9] ==
'+' || ptr[num9] ==
'-') && ptr[num9 + 1] ==
'0'))
973 while (++num9 <
format.Length && ptr[num9] ==
'0')
1002 number.scale += num8;
1003 int pos = (flag ? num3 : (number.scale + num3 - num4));
1017 number.sign =
false;
1021 num5 = ((num5 < num4) ? (num4 - num5) : 0);
1022 num6 = ((num6 > num4) ? (num4 - num6) : 0);
1032 num10 = ((number.scale > num4) ? number.scale : num4);
1033 num11 = number.scale - num4;
1038 if (flag2 &&
info.NumberGroupSeparator.Length > 0)
1040 int[] numberGroupSizes =
info.NumberGroupSizes;
1043 int num14 = numberGroupSizes.Length;
1046 i = numberGroupSizes[num13];
1049 int num16 = num10 + ((num11 < 0) ? num11 : 0);
1050 for (
int num17 = ((num5 > num16) ? num5 : num16); num17 > i; i += num15)
1057 if (num12 >= span.
Length)
1059 int[]
array =
new int[span.Length * 2];
1064 if (num13 < num14 - 1)
1067 num15 = numberGroupSizes[num13];
1071 if (number.sign && num2 == 0)
1073 sb.Append(
info.NegativeSign);
1078 char* ptr2 = digits;
1080 while (num9 <
format.Length && (c = ptr3[num9++]) != 0 && c !=
';')
1082 if (num11 > 0 && (c ==
'#' || c ==
'.' || c ==
'0'))
1086 sb.Append((*ptr2 != 0) ? (*(ptr2++)) :
'0');
1087 if (flag2 && num10 > 1 && num12 >= 0 && num10 == span[num12] + 1)
1089 sb.Append(
info.NumberGroupSeparator);
1103 c = ((num10 <= num5) ?
'0' :
'\0');
1107 c = ((*ptr2 != 0) ? (*(ptr2++)) : ((num10 > num6) ?
'0' :
'\0'));
1112 if (flag2 && num10 > 1 && num12 >= 0 && num10 == span[num12] + 1)
1114 sb.Append(
info.NumberGroupSeparator);
1121 if (!(num10 != 0 || flag3) && (num6 < 0 || (num4 < num3 && *ptr2 != 0)))
1123 sb.Append(
info.NumberDecimalSeparator);
1128 sb.Append(
info.PerMilleSymbol);
1131 sb.Append(
info.PercentSymbol);
1135 while (num9 <
format.Length && ptr3[num9] != 0 && ptr3[num9] != c)
1137 sb.Append(ptr3[num9++]);
1139 if (num9 <
format.Length && ptr3[num9] != 0)
1145 if (num9 <
format.Length && ptr3[num9] != 0)
1147 sb.Append(ptr3[num9++]);
1153 bool positiveSign =
false;
1157 if (num9 <
format.Length && ptr3[num9] ==
'0')
1161 else if (num9 + 1 <
format.Length && ptr3[num9] ==
'+' && ptr3[num9 + 1] ==
'0')
1163 positiveSign =
true;
1165 else if (num9 + 1 >=
format.Length || ptr3[num9] !=
'-' || ptr3[num9 + 1] !=
'0')
1170 while (++num9 <
format.Length && ptr3[num9] ==
'0')
1178 int value = ((*digits != 0) ? (number.scale - num4) : 0);
1184 if (num9 <
format.Length)
1186 if (ptr3[num9] ==
'+' || ptr3[num9] ==
'-')
1188 sb.Append(ptr3[num9++]);
1190 while (num9 <
format.Length && ptr3[num9] ==
'0')
1192 sb.Append(ptr3[num9++]);
1210 fixed (
char* ptr = digits)
1214 number.precision = precision;
1215 number.scale = scale;
1233 number.overrideDigits = (
char*)1;
1242 scale = number.
scale;
static byte Min(byte val1, byte val2)
static unsafe ReadOnlySpan< char > CreateReadOnlySpanFromNullTerminated(char *value)
static string Argument_BadFormatSpecifier
StringBuilder Append(char value, int repeatCount)
void CopyTo(Span< T > destination)