Skip to content · ⁨Lompat ke konten⁩

Count the 1-bits · ⁨Kira bit 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.

Bahasa Indonesia

Hitung bit-1

Setiap bilangan bulat tak-ber tanda disimpan dalam bentuk biner. Kembalikan berapa banyak bitnya yang 1 (ini disebut population count). Periksa bit terendah dengan x & 1u, lalu geser x ke kanan satu tempat dengan x >>= 1, sampai x menjadi 0.

Log in or create account · ⁨Masuk atau buat akun⁩

IGCSE, A-Level & AP