1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Fix ToString() for int32.MinValue and int64.MinValue

This commit is contained in:
Piotr Myśliński 2020-05-25 22:32:15 +02:00
parent 323f984a72
commit bec7dff380
No known key found for this signature in database
GPG key ID: 1E8505076BB60E01
2 changed files with 15 additions and 15 deletions

View file

@ -54,15 +54,15 @@ namespace System
char8[] strChars = scope:: char8[16];
int32 char8Idx = 14;
int32 valLeft = (int32)this;
bool isNeg = false;
if (valLeft < 0)
bool isNeg = true;
if (valLeft >= 0)
{
valLeft = -valLeft;
isNeg = true;
isNeg = false;
}
while (valLeft > 0)
while (valLeft < 0)
{
strChars[char8Idx] = (char8)('0' + (valLeft % 10));
strChars[char8Idx] = (char8)('0' - (valLeft % 10));
valLeft /= 10;
char8Idx--;
}
@ -80,16 +80,16 @@ namespace System
char8[] strChars = scope:: char8[16];
int32 char8Idx = 14;
int32 valLeft = (int32)this;
bool isNeg = false;
bool isNeg = true;
int minNumeralsLeft = minNumerals;
if (valLeft < 0)
if (valLeft >= 0)
{
valLeft = -valLeft;
isNeg = true;
isNeg = false;
}
while ((valLeft > 0) || (minNumeralsLeft > 0))
while ((valLeft < 0) || (minNumeralsLeft > 0))
{
strChars[char8Idx] = (char8)('0' + (valLeft % 10));
strChars[char8Idx] = (char8)('0' - (valLeft % 10));
valLeft /= 10;
char8Idx--;
minNumeralsLeft--;

View file

@ -71,16 +71,16 @@ namespace System
char8[] strChars = scope:: char8[22];
int32 char8Idx = 20;
int64 valLeft = (int64)this;
bool isNeg = false;
bool isNeg = true;
int minNumeralsLeft = 0;
if (valLeft < 0)
if (valLeft >= 0)
{
valLeft = -valLeft;
isNeg = true;
isNeg = false;
}
while ((valLeft > 0) || (minNumeralsLeft > 0))
while ((valLeft < 0) || (minNumeralsLeft > 0))
{
strChars[char8Idx] = (char8)('0' + (valLeft % 10));
strChars[char8Idx] = (char8)('0' - (valLeft % 10));
valLeft /= 10;
char8Idx--;
minNumeralsLeft--;