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 (يسمى هذا عدّد السكان). انظر إلى أدنى بت يساوي x & 1u، ثم قم بإزاحة x لليمين بمقدار واحد باستخدام x >>= 1، حتى تصبح x مساوية لـ 0.

Log in or create account · ⁨تسجيل الدخول أو إنشاء حساب⁩

IGCSE, A-Level & AP