1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-22 17:48:01 +02:00

Merge pull request #294 from pmysl/master

Fix ToString() for int32.MinValue and int64.MinValue
This commit is contained in:
Brian Fiete 2020-05-25 15:28:19 -07:00 committed by GitHub
commit 17ca597bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 60 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--;