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

◆ TryNegativeInt32ToDecStr()

static unsafe bool System.Number.TryNegativeInt32ToDecStr ( int value,
int digits,
string sNegative,
Span< char > destination,
out int charsWritten )
inlinestaticprivate

Definition at line 2274 of file Number.cs.

2275 {
2276 if (digits < 1)
2277 {
2278 digits = 1;
2279 }
2280 int num = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length;
2281 if (num > destination.Length)
2282 {
2283 charsWritten = 0;
2284 return false;
2285 }
2286 charsWritten = num;
2287 fixed (char* ptr = &MemoryMarshal.GetReference(destination))
2288 {
2289 char* ptr2 = UInt32ToDecChars(ptr + num, (uint)(-value), digits);
2290 for (int num2 = sNegative.Length - 1; num2 >= 0; num2--)
2291 {
2292 *(--ptr2) = sNegative[num2];
2293 }
2294 }
2295 return true;
2296 }
static unsafe byte * UInt32ToDecChars(byte *bufferEnd, uint value, int digits)
Definition Number.cs:2360

References System.Buffers.Text.FormattingHelpers.CountDigits(), System.destination, System.Math.Max(), System.Number.UInt32ToDecChars(), and System.value.

Referenced by System.Number.TryFormatInt32().