After two days thinking your explanation, i have understand very well
now, thanks very much!
There are two point with my acquaintance:
1. --x at the first, it advoid next power of two is double with
the power of two, like 1000(dec is 8), it will became 16.
2. i=1 (doing i++ in the for loop), it
On Apr 1, 11:16 pm, a a harvey.a...@gmail.com wrote:
But i can't understand the following algorithm
function nextHighestPowerOfTwo(x) {
--x;
for (var i = 1; i 32; i = 1) {
x = x | x i;
}
return x + 1;
}
On the first loop, take the value and smear its bits
once
2 matches
Mail list logo