Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic


Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction popcnt. This instruction calculates the number of bits of the parameter that are set to 1.

int _mm_popcnt_u32 (
   unsigned int a



[in] a

An integer.

The number of bits set to one in a.




x86, x64

Header file <nmmintrin.h>

Before you use this intrinsic, software must ensure that the processor supports the instruction.

#include <stdio.h>
#include <nmmintrin.h>

int main ()
    unsigned int a = 0x2F63A150;

    int res = _mm_popcnt_u32(a);

    printf_s("Result res should be 14: %d\n", res);

    return 0;
Result res should be 14: 14
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.