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

◆ ConvertToDecimal()

static unsafe string System.Xml.Xsl.Runtime.NumberFormatter.ConvertToDecimal ( double val,
int minLen,
char zero,
string groupSeparator,
int groupSize )
inlinestaticprivate

Definition at line 146 of file NumberFormatter.cs.

147 {
148 string text = XPathConvert.DoubleToString(val);
149 int num = zero - 48;
150 int length = text.Length;
151 int num2 = Math.Max(length, minLen);
152 char* ptr;
153 char c;
154 checked
155 {
156 if (groupSize != 0)
157 {
159 }
160 if (num2 == length && num == 0)
161 {
162 return text;
163 }
164 if (groupSize == 0 && num == 0)
165 {
166 return text.PadLeft(num2, zero);
167 }
168 ptr = stackalloc char[num2];
169 c = ((groupSeparator.Length > 0) ? groupSeparator[0] : ' ');
170 }
171 fixed (char* ptr2 = text)
172 {
173 char* ptr3 = ptr2 + length - 1;
174 char* ptr4 = ptr + num2 - 1;
175 int num3 = groupSize;
176 while (true)
177 {
178 *(ptr4--) = ((ptr3 >= ptr2) ? ((char)(*(ptr3--) + num)) : zero);
179 if (ptr4 < ptr)
180 {
181 break;
182 }
183 if (--num3 == 0)
184 {
185 *(ptr4--) = c;
186 num3 = groupSize;
187 }
188 }
189 }
190 return new string(ptr, 0, num2);
191 }

References System.Xml.Dictionary, System.Xml.Xsl.XPathConvert.DoubleToString(), System.length, System.Math.Max(), and System.text.

Referenced by System.Xml.Xsl.Runtime.NumberFormatter.FormatItem().