System.NumberFormatter.AppendIntegerStringWithGroupSeparator C# (CSharp) Méthode

AppendIntegerStringWithGroupSeparator() private méthode

private AppendIntegerStringWithGroupSeparator ( int groups, string groupSeparator ) : void
groups int
groupSeparator string
Résultat void
		private void AppendIntegerStringWithGroupSeparator (int[] groups, string groupSeparator)
		{
			if (IsZeroInteger) {
				Append ('0');
				return;
			}

			int total = 0;
			int groupIndex = 0;
			for (int i = 0; i < groups.Length; i++) {
				total += groups [i];
				if (total <= _decPointPos)
					groupIndex = i;
				else
					break;
			}

			if (groups.Length > 0 && total > 0) {
				int counter;
				int groupSize = groups [groupIndex];
				int fraction = _decPointPos > total ? _decPointPos - total : 0;
				if (groupSize == 0) {
					while (groupIndex >= 0 && groups [groupIndex] == 0)
						groupIndex--;

					groupSize = fraction > 0 ? fraction : groups [groupIndex];
				}
				if (fraction == 0)
					counter = groupSize;
				else {
					groupIndex += fraction / groupSize;
					counter = fraction % groupSize;
					if (counter == 0)
						counter = groupSize;
					else
						groupIndex++;
				}

				if (total >= _decPointPos) {
					int lastGroupSize = groups [0];
					if (total > lastGroupSize) {
						int lastGroupDiff = -(lastGroupSize - _decPointPos);
						int lastGroupMod;

						if (lastGroupDiff < lastGroupSize)
							counter = lastGroupDiff;
						else if (lastGroupSize > 0 && (lastGroupMod = _decPointPos % lastGroupSize) > 0)
							counter = lastGroupMod;
					}
				}
				
				for (int i = 0; ;) {
					if ((_decPointPos - i) <= counter || counter == 0) {
						AppendDigits (_digitsLen - _decPointPos, _digitsLen - i);
						break;
					}
					AppendDigits (_digitsLen - i - counter, _digitsLen - i);
					i += counter;
					Append (groupSeparator);
					if (--groupIndex < groups.Length && groupIndex >= 0)
						groupSize = groups [groupIndex];
					counter = groupSize;
				}
			}
			else {
				AppendDigits (_digitsLen - _decPointPos, _digitsLen);
			}
		}