ee.Array.bitsToArray
Converts 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.
Usage | Returns | ee.Array.bitsToArray(input) | Array |
Argument | Type | Details | input | Number | The integer to transform. |
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
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
display(ee.Array.bitsToArray(0)) # [0]
display(ee.Array.bitsToArray(1)) # [1]
display(ee.Array.bitsToArray(5)) # [1, 0 , 1]
display(ee.Array.bitsToArray(0xFF)) # [1, 1, 1, 1, 1, 1, 1, 1]
display(ee.Array.bitsToArray(-1)) # Array of 64 "1" values
display(ee.Array.bitsToArray(-1).toInt8()) # Array of 64 "1" values
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-19 UTC.
[null,null,["Last updated 2024-09-19 UTC."],[[["`ee.Array.bitsToArray()` converts an integer into an array representing its binary representation, with each element being a bit (0 or 1)."],["The resulting array's length corresponds to the position of the highest set bit in the input integer, plus one."],["An input value of 0 results in an array containing a single element: 0."],["For negative integers like -1, the function generates an array of 64 elements, all set to 1, representing its two's complement form."]]],[]]