1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-30 05:15:59 +02:00

Fix ToString formatting for uint32 (cascading to uint16, uint8 and uint)

This commit is contained in:
Thimo 2020-10-28 23:17:51 +01:00
parent 114f5a3c92
commit 73ec76540e

View file

@ -57,13 +57,7 @@ namespace System
// Dumb, make better. // Dumb, make better.
char8[] strChars = scope:: char8[16]; char8[] strChars = scope:: char8[16];
int32 char8Idx = 14; int32 char8Idx = 14;
int32 valLeft = (int32)this; uint32 valLeft = (uint32)this;
bool isNeg = false;
if (valLeft < 0)
{
valLeft = -valLeft;
isNeg = true;
}
while (valLeft > 0) while (valLeft > 0)
{ {
strChars[char8Idx] = (char8)('0' + (valLeft % 10)); strChars[char8Idx] = (char8)('0' + (valLeft % 10));
@ -72,8 +66,6 @@ namespace System
} }
if (char8Idx == 14) if (char8Idx == 14)
strChars[char8Idx--] = '0'; strChars[char8Idx--] = '0';
if (isNeg)
strChars[char8Idx--] = '-';
char8* char8Ptr = &strChars[char8Idx + 1]; char8* char8Ptr = &strChars[char8Idx + 1];
strBuffer.Append(char8Ptr); strBuffer.Append(char8Ptr);
} }
@ -83,14 +75,8 @@ namespace System
// Dumb, make better. // Dumb, make better.
char8[] strChars = scope:: char8[16]; char8[] strChars = scope:: char8[16];
int32 char8Idx = 14; int32 char8Idx = 14;
int32 valLeft = (int32)this; uint32 valLeft = (uint32)this;
bool isNeg = false;
int minNumeralsLeft = minNumerals; int minNumeralsLeft = minNumerals;
if (valLeft < 0)
{
valLeft = -valLeft;
isNeg = true;
}
while ((valLeft > 0) || (minNumeralsLeft > 0)) while ((valLeft > 0) || (minNumeralsLeft > 0))
{ {
strChars[char8Idx] = (char8)('0' + (valLeft % 10)); strChars[char8Idx] = (char8)('0' + (valLeft % 10));
@ -100,8 +86,6 @@ namespace System
} }
if (char8Idx == 14) if (char8Idx == 14)
strChars[char8Idx--] = '0'; strChars[char8Idx--] = '0';
if (isNeg)
strChars[char8Idx--] = '-';
char8* char8Ptr = &strChars[char8Idx + 1]; char8* char8Ptr = &strChars[char8Idx + 1];
strBuffer.Append(char8Ptr); strBuffer.Append(char8Ptr);
} }