From e7e8164d1f4baccb1c1bfd7c370342456b1a8f29 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sun, 16 Aug 2015 21:54:59 +0000 Subject: Couldn't print out the minimum value for any given signed integer. I fixed the code, but I have a feeling the fix could be much better. I'll look into it later on. --- src/stable/formatter.h | 8 ++++++++ src/tests/print.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/stable/formatter.h b/src/stable/formatter.h index 493bca4..fc430f3 100644 --- a/src/stable/formatter.h +++ b/src/stable/formatter.h @@ -90,6 +90,14 @@ namespace Bu { int c = i%fLast.uRadix; i /= fLast.uRadix; + + // I'm not thrilled with this solution, but it's the best I can + // do right now. I'll have to give this more thought later. + if( i < 0 ) + { + i = -i; + c = -c; + } buf[j] = (char)((c<10)?('0'+c):(cBase+c-10)); if( i == 0 ) { diff --git a/src/tests/print.cpp b/src/tests/print.cpp index bee8cf8..dcd1033 100644 --- a/src/tests/print.cpp +++ b/src/tests/print.cpp @@ -8,6 +8,11 @@ int upper() int main() { + int32_t x = INT32_MIN; + int32_t y = -x; + Bu::sio << INT32_MIN; + Bu::println("Attack: Rolled %1 against %2 using %3."). + arg( INT32_MIN ).arg( 45.0 ).arg( Bu::String("Longsword") ); Bu::print("hello there %1!\n").arg("Bob"); Bu::println("This is %1 crazy, like %2 times over!"). -- cgit v1.2.3