MCPcopy Create free account
hub / github.com/sql-js/sql.js / reSign

Function reSign

js/sql-debug.js:1341–1353  ·  view source on GitHub ↗
(value, bits, ignore)

Source from the content-addressed store, hash-verified

1339 : Math.pow(2, bits) + value;
1340}
1341function reSign(value, bits, ignore) {
1342 if (value <= 0) {
1343 return value;
1344 }
1345 var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
1346 : Math.pow(2, bits-1);
1347 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
1348 // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
1349 // TODO: In i64 mode 1, resign the two parts separately and safely
1350 value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
1351 }
1352 return value;
1353}
1354
1355assert(Math['imul'] && Math['fround'] && Math['clz32'] && Math['trunc'], 'this is a legacy browser, build with LEGACY_VM_SUPPORT');
1356

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…