I'm trying to maximize my FLOPS in NodeJS, so I want to add using bitwise operations.
So:
var a = 6, b = 12;
a + b
Instead:
var add = function (a, b) {
var carry, result, shiftedcarry;
carry = a & b,
result = a ^ b;
while (carry !== 0) {
shiftedcarry = carry << 1;
carry = result & shiftedcarry;
result ^= shiftedcarry;
}
return result;
}
add(a, b);
However, I found SO answers that said bitwise operations are slower in Javascript due to casting. Is there anyway to bypass this problem (like with a V8 extension or something)?
The reason I'm so focused on increasing my FLOPS is because I'm thinking of running a NodeJS experiment on a supercomputer.