mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
743ed413f6
[no changelog]
12 lines
310 B
C
12 lines
310 B
C
|
|
#include <stdint.h>
|
|
|
|
uint32_t hamming_weight(uint32_t value) {
|
|
value = value - ((value >> 1) & 0x55555555);
|
|
value = (value & 0x33333333) + ((value >> 2) & 0x33333333);
|
|
value = (value + (value >> 4)) & 0x0F0F0F0F;
|
|
value = value + (value >> 8);
|
|
value = value + (value >> 16);
|
|
return value & 0x3F;
|
|
}
|