diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 520d278e..0e6ddee8 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1537,7 +1537,8 @@ function makeRounding(value, bits, signed, floatConversion) { // TODO: handle roundings of i64s assert(bits); // C rounds to 0 (-5.5 to -5, +5.5 to 5), while JS has no direct way to do that. - if (bits <= 32 && signed) return '((' + value + ')|0)'; // This is fast and even correct, for all cases + if (bits <= 32 && signed) return '((' + value + ')&-1)'; // This is fast and even correct, for all cases. Note that it is the same + // as |0, but &-1 hints to the js optimizer that this is a rounding correction // Do Math.floor, which is reasonably fast, if we either don't care, or if we can be sure // the value is non-negative if (!correctRoundings() || (!signed && !floatConversion)) return 'Math.floor(' + value + ')'; |