I have the following, working prototype code:
function int2str(int, bits) {
const str = int.toString(2);
var ret = '';
for (var i = 0; i < (bits - str.length); ++i) {
ret += '0';
}
ret += str;
return ret;
}
function high32(u64) {
return parseInt(int2str(u64, 64).substr(0, 32), 2);
}
function low32(u64) {
return parseInt(int2str(u64, 64).substr(32, 32), 2);
}
function combine(low, high) {
return parseInt(int2str(high, 32) + int2str(low, 32), 2);
}
Can I do this more efficiently, without strings?
(Bitwise operators in Javascript cast to a 32-bit integer, making them useless.)