ee.Array.bitsToArray
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แปลงบิตของจำนวนเต็มเป็นอาร์เรย์ อาร์เรย์มีองค์ประกอบมากเท่ากับตำแหน่งของบิตที่ตั้งค่าสูงสุด หรือมี 0 เพียงตัวเดียวสำหรับค่า 0
การใช้งาน | การคืนสินค้า |
---|
ee.Array.bitsToArray(input) | อาร์เรย์ |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
input | ตัวเลข | จำนวนเต็มที่จะเปลี่ยน |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (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
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
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
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eee.Array.bitsToArray()\u003c/code\u003e converts an integer into an array representing its binary representation, with each element being a bit (0 or 1).\u003c/p\u003e\n"],["\u003cp\u003eThe resulting array's length corresponds to the position of the highest set bit in the input integer, plus one.\u003c/p\u003e\n"],["\u003cp\u003eAn input value of 0 results in an array containing a single element: 0.\u003c/p\u003e\n"],["\u003cp\u003eFor negative integers like -1, the function generates an array of 64 elements, all set to 1, representing its two's complement form.\u003c/p\u003e\n"]]],[],null,["# ee.Array.bitsToArray\n\nConverts 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.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------------|---------|\n| `ee.Array.bitsToArray(input)` | Array |\n\n| Argument | Type | Details |\n|----------|--------|---------------------------|\n| `input` | Number | The integer to transform. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint(ee.Array.bitsToArray(0)); // [0]\nprint(ee.Array.bitsToArray(1)); // [1]\nprint(ee.Array.bitsToArray(5)); // [1, 0 , 1]\nprint(ee.Array.bitsToArray(0xFF)); // [1,1,1,1,1,1,1,1]\nprint(ee.Array.bitsToArray(-1)); // Array of 64 \"1\" values\nprint(ee.Array.bitsToArray(-1).toInt8()); // Array of 64 \"1\" values\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ndisplay(ee.Array.bitsToArray(0)) # [0]\ndisplay(ee.Array.bitsToArray(1)) # [1]\ndisplay(ee.Array.bitsToArray(5)) # [1, 0 , 1]\ndisplay(ee.Array.bitsToArray(0xFF)) # [1, 1, 1, 1, 1, 1, 1, 1]\ndisplay(ee.Array.bitsToArray(-1)) # Array of 64 \"1\" values\ndisplay(ee.Array.bitsToArray(-1).toInt8()) # Array of 64 \"1\" values\n```"]]