Skip to content · ⁨본문 바로가기⁩

Count the 1-bits · ⁨1-비트 세기⁩

English

Count the 1-bits

Every unsigned integer is stored in binary. Return how many of its bits are 1 (this is called the population count). Look at the lowest bit with x & 1u, then shift x right by one with x >>= 1, until x becomes 0.

한국어

1비트 세기

모든 부호 없는 정수는 이진수로 저장됩니다. 이 중 1개(이를 인구 수라고 함)가 1인지 반환합니다. x & 1u인 가장 낮은 비트를 확인한 후, x를 x >>= 1으로 한 번씩 오른쪽으로 이동시켜 x이 0이 될 때까지 반복합니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP