It’s much better to make your own function that uses bitwise operations to do addition.
functionadd(a, b) {
while (b !== 0) {
// Calculate carrylet carry = a & b;
// Sum without carry
a = a ^ b;
// Shift carry to the left
b = carry << 1;
}
return a;
}
It’s much better to make your own function that uses bitwise operations to do addition.
function add(a, b) { while (b !== 0) { // Calculate carry let carry = a & b; // Sum without carry a = a ^ b; // Shift carry to the left b = carry << 1; } return a; }
(For certain definitions of better.)