aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-09-14 18:08:52 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-09-14 18:08:52 -0700
commitce07f2aa7735c267785115c23f28321f61c7b250 (patch)
tree03ea71dbf30887f38dc585b678d6299b5e608661 /src
parent55013f30bce701468b5dcdd00dd0df3d53c75c33 (diff)
intentionally do reSign in printing %d
Diffstat (limited to 'src')
-rw-r--r--src/library.js16
-rw-r--r--src/runtime.js2
2 files changed, 10 insertions, 8 deletions
diff --git a/src/library.js b/src/library.js
index 1925fb04..84ea9243 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2338,9 +2338,9 @@ LibraryManager.library = {
var argText;
var prefix = '';
if (next == 'd'.charCodeAt(0) || next == 'i'.charCodeAt(0)) {
- argText = currAbsArg.toString(10);
+ argText = reSign(currArg, 8 * argSize, 1).toString(10);
} else if (next == 'u'.charCodeAt(0)) {
- argText = unSign(currArg, 8 * argSize).toString(10);
+ argText = unSign(currArg, 8 * argSize, 1).toString(10);
currArg = Math.abs(currArg);
} else if (next == 'o'.charCodeAt(0)) {
argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);
@@ -2377,11 +2377,13 @@ LibraryManager.library = {
}
}
- // Add sign.
- if (currArg < 0) {
- prefix = '-' + prefix;
- } else if (flagAlwaysSigned) {
- prefix = '+' + prefix;
+ // Add sign if needed
+ if (flagAlwaysSigned) {
+ if (currArg < 0) {
+ prefix = '-' + prefix;
+ } else {
+ prefix = '+' + prefix;
+ }
}
// Add padding.
diff --git a/src/runtime.js b/src/runtime.js
index 7e3c7b84..719be637 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -268,7 +268,7 @@ function reSign(value, bits, ignore, sig) {
#if CHECK_SIGNS
var noted = false;
#endif
- if (value >= half) {
+ if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
#if CHECK_SIGNS
if (!ignore) {
CorrectionsMonitor.note('ReSign', 0, sig);