diff options
author | Mike Buland <eichlan@xagasoft.com> | 2015-08-16 21:54:59 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2015-08-16 21:54:59 +0000 |
commit | e7e8164d1f4baccb1c1bfd7c370342456b1a8f29 (patch) | |
tree | 0a460a7a8098dba5ada1680798b2298792965078 | |
parent | 598af2576c98e45161ca21662434423f349958cc (diff) | |
download | libbu++-e7e8164d1f4baccb1c1bfd7c370342456b1a8f29.tar.gz libbu++-e7e8164d1f4baccb1c1bfd7c370342456b1a8f29.tar.bz2 libbu++-e7e8164d1f4baccb1c1bfd7c370342456b1a8f29.tar.xz libbu++-e7e8164d1f4baccb1c1bfd7c370342456b1a8f29.zip |
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.
Diffstat (limited to '')
-rw-r--r-- | src/stable/formatter.h | 8 | ||||
-rw-r--r-- | src/tests/print.cpp | 5 |
2 files changed, 13 insertions, 0 deletions
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 | |||
90 | { | 90 | { |
91 | int c = i%fLast.uRadix; | 91 | int c = i%fLast.uRadix; |
92 | i /= fLast.uRadix; | 92 | i /= fLast.uRadix; |
93 | |||
94 | // I'm not thrilled with this solution, but it's the best I can | ||
95 | // do right now. I'll have to give this more thought later. | ||
96 | if( i < 0 ) | ||
97 | { | ||
98 | i = -i; | ||
99 | c = -c; | ||
100 | } | ||
93 | buf[j] = (char)((c<10)?('0'+c):(cBase+c-10)); | 101 | buf[j] = (char)((c<10)?('0'+c):(cBase+c-10)); |
94 | if( i == 0 ) | 102 | if( i == 0 ) |
95 | { | 103 | { |
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() | |||
8 | 8 | ||
9 | int main() | 9 | int main() |
10 | { | 10 | { |
11 | int32_t x = INT32_MIN; | ||
12 | int32_t y = -x; | ||
13 | Bu::sio << INT32_MIN; | ||
14 | Bu::println("Attack: Rolled %1 against %2 using %3."). | ||
15 | arg( INT32_MIN ).arg( 45.0 ).arg( Bu::String("Longsword") ); | ||
11 | Bu::print("hello there %1!\n").arg("Bob"); | 16 | Bu::print("hello there %1!\n").arg("Bob"); |
12 | 17 | ||
13 | Bu::println("This is %1 crazy, like %2 times over!"). | 18 | Bu::println("This is %1 crazy, like %2 times over!"). |