aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-03-21 19:48:24 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-03-21 19:48:24 -0700
commit98f6e8924d27246f40f50ec3f75084f1f04b6459 (patch)
tree3df59f43576082ce486d73de8ab5ccc264fdbca2 /src/preamble.js
parentee9393ae048547f8d0d8aef6c00a197fe00234b0 (diff)
do not un/reSign constants
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 2eb745a5..9f457a5c 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -383,32 +383,8 @@ function intArrayToString(array) {
return ret;
}
-// Converts a value we have as signed, into an unsigned value. For
-// example, -1 in int32 would be a very large number as unsigned.
-function unSign(value, bits, ignore) {
- if (value >= 0) return value;
-#if CHECK_SIGNS
- if (!ignore) CorrectionsMonitor.note('UnSign');
-#endif
- return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
- : Math.pow(2, bits) + value;
- // TODO: clean up previous line
-}
-
-// Converts a value we have as unsigned, into a signed value. For
-// example, 200 in a uint8 would be a negative number.
-function reSign(value, bits, ignore) {
- if (value <= 0) return value;
- var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
- : Math.pow(2, bits-1);
- if (value >= half) {
-#if CHECK_SIGNS
- if (!ignore) CorrectionsMonitor.note('ReSign');
-#endif
- value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
- }
- return value;
-}
+var unSign = {{{ unSign.toString() }}}
+var reSign = {{{ reSign.toString() }}}
// === Body ===