ee.Number.bitCount

Calculates the number of one-bits in the 64-bit two's complement binary representation of the input.

UsageReturns
Number.bitCount()Number
ArgumentTypeDetails
this: inputNumber

The input value.

Examples

Code Editor (JavaScript)

print(ee.Number(0).bitCount());       // [0]
print(ee.Number(1).bitCount());       // [1]
print(ee.Number(2).bitCount());       // [1]
print(ee.Number(3).bitCount());       // [2]
print(ee.Number(0xFFFF).bitCount());  // [16]

// https://en.wikipedia.org/wiki/Two's_complement signed values.
print(ee.Number(-1).bitCount());                       // [64]
print(ee.Number(-1, ee.PixelType.int8()).bitCount());  // [64]
print(ee.Number(-2).bitCount());                       // [63]