diff --git a/BeefLibs/corlib/src/Int32.bf b/BeefLibs/corlib/src/Int32.bf index 037af887..72081c9e 100644 --- a/BeefLibs/corlib/src/Int32.bf +++ b/BeefLibs/corlib/src/Int32.bf @@ -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--; diff --git a/BeefLibs/corlib/src/Int64.bf b/BeefLibs/corlib/src/Int64.bf index e34f59c7..3609728c 100644 --- a/BeefLibs/corlib/src/Int64.bf +++ b/BeefLibs/corlib/src/Int64.bf @@ -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--;