diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-05-22 14:58:12 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-05-22 14:58:12 -0700 |
commit | d12bc83b82e1e95b292cb280e00987ee3fa97b41 (patch) | |
tree | a6c0ae3a607112a171fe25ff16bd07ab157d7c81 /src | |
parent | 469d4e73bf4d2bded855f063fe8dbda7a8ca9648 (diff) |
note on CORRECT_OVERFLOWS
Diffstat (limited to 'src')
-rw-r--r-- | src/preamble.js | 3 | ||||
-rw-r--r-- | src/settings.js | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/preamble.js b/src/preamble.js index 847d2d95..eaa02c90 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -129,7 +129,8 @@ function cRound(x) { //======================================== // Debugging tools - Mathop overflows //======================================== -function CHECK_OVERFLOW(value, bits) { +function CHECK_OVERFLOW(value, bits, ignore) { + if (ignore) return value; if (value === Infinity || value === -Infinity || Math.abs(value) >= Math.pow(2, bits)) { CorrectionsMonitor.note('Overflow'); } diff --git a/src/settings.js b/src/settings.js index 0243a191..249c8224 100644 --- a/src/settings.js +++ b/src/settings.js @@ -61,6 +61,9 @@ CHECK_OVERFLOWS = 0; // Add code that checks for overflows in integer math opera // some factor, in order to get 'random' hash values - by taking // that |value & hash_table_size| - then multiplying enough times will overflow. // But instead, you can do |value = value & 30_BITS| in each iteration. + // Note: CHECK_OVERFLOWS checks for overflows *after* CORRECT_OVERFLOWS + // has operated (if it has). So you must run *without* CORRECT_OVERFLOWS + // for this option to work. (Sorry for the discrepancy with CHECK_SIGNS - FIXME.) CORRECT_OVERFLOWS = 1; // Experimental code that tries to prevent unexpected JS overflows in integer // mathops, by doing controlled overflows (sort of parallel to a CPU). // Note that as mentioned above in CHECK_OVERFLOWS, the best thing is to |