Skip to content

Latest commit

 

History

History
12 lines (12 loc) · 212 Bytes

47.不用加减乘除做加法.md

File metadata and controls

12 lines (12 loc) · 212 Bytes
function Add(num1, num2)
{
    var sum, carry;
    do {
        sum = num1 ^ num2;
        carry = (num1 & num2) << 1;
        num1 = sum;
        num2 = carry;
    } while (num2 !== 0);
    return num1;
}