Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bitwise Operators! solution in Creative category for Multiply (Intro) by lolucky
var addTwo =(a,b)=> {
while (b) [ a, b ] = [ a^b, (a&b) << 1 ]
return a
}
var multTwo =(a,b)=> {
for(var r=0; a; b<<=1, a>>=1)
if (a&1) r = addTwo(r,b)
return r
}
// 13*5 = 8*5 + 4*5 + 1*5 = 5<<3 + 5<<2 + 5<<1
Dec. 31, 2020
Comments: