ee.Array.bitsToArray

Stay organized with collections Save and categorize content based on your preferences.
Convert the bits of an integer to an Array. The array has as many elements as the position of the highest set bit, or a single 0 for a value of 0.

UsageReturns
ee.Array.bitsToArray(input)Array
ArgumentTypeDetails
inputNumber

Examples

Code Editor (JavaScript)

print(ee.Array.bitsToArray(0));  // [0]
print(ee.Array.bitsToArray(1));  // [1]
print(ee.Array.bitsToArray(5));  // [1, 0 , 1]
print(ee.Array.bitsToArray(0xFF));  // [1,1,1,1,1,1,1,1]
print(ee.Array.bitsToArray(-1));  // Array of 64 "1" values
print(ee.Array.bitsToArray(-1).toInt8());  // Array of 64 "1" values