mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Shifted method has been changed
This commit is contained in:
parent
ca3d16dcce
commit
813b7a85df
@ -10,8 +10,8 @@ export default function countSetBits(originalNumber) {
|
|||||||
// Add last bit of the number to the sum of set bits.
|
// Add last bit of the number to the sum of set bits.
|
||||||
setBitsCount += number & 1;
|
setBitsCount += number & 1;
|
||||||
|
|
||||||
// Shift number right by one bit to investigate other bits.
|
// Arithmetic Shift number right by one bit to investigate other bits.
|
||||||
number >>>= 1;
|
number >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return setBitsCount;
|
return setBitsCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user