oneBitCount property

  1. @Since.new("3.13")
int get oneBitCount

The number of 1 bits in the binary representation of this integer.

On JavaScript platforms, only the least significant 32 bits are used. On native platforms, the 64-bit signed integer is used directly.

The one-bit count is the number of 1 digits in the binary representation of that integer. A negative integer has one-digits up to the size of integer that the platform uses for bit operations (64-bit on native, 32-bit on the web). The value of n.oneBitCount + (~n).oneBitCount is always the size the platform uses for bit operations (on the web, at least if the value starts out as a 32-bit integer).

0.oneBitCount;    // 0
1.oneBitCount;    // 1
7.oneBitCount;    // 3
(-1).oneBitCount; // 64 on native, 32 on the web

Implementation

@Since("3.13")
int get oneBitCount;