ประกาศ : โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์ เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ส่งความคิดเห็น
ee.Number.toInt32
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แปลงค่าอินพุตเป็นจำนวนเต็มแบบมีเครื่องหมาย 32 บิต
การใช้งาน การคืนสินค้า Number. toInt32 ()
ตัวเลข
อาร์กิวเมนต์ ประเภท รายละเอียด ดังนี้ input
ตัวเลข ค่าอินพุต
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Cast a number to signed 32-bit integer: [-2147483648, 2147483647].
var number = ee . Number ( 100 );
print ( 'Number:' , number );
var int32Number = number . toInt32 ();
print ( 'Number cast to int32:' , int32Number );
/**
* Casting numbers to int32 that are outside of its range and precision can
* modify the resulting value, note the behavior of the following scenarios.
*/
// A floating point number cast to int32 loses decimal precision.
var float = ee . Number ( 1.7 );
print ( 'Floating point value:' , float );
var floatToInt32 = float . toInt32 ();
print ( 'Floating point value cast to int32:' , floatToInt32 );
// A number greater than int32 range max cast to int32 becomes int32 range max.
var INT32_MAX = 2147483647 ;
var outOfRangeHi = ee . Number ( INT32_MAX + 12345 );
print ( 'Greater than int32 max:' , outOfRangeHi );
var outOfRangeHiToInt32 = outOfRangeHi . toInt32 ();
print ( 'Greater than int32 max cast to int32 becomes int32 max:' , outOfRangeHiToInt32 );
// A number greater than int32 range min cast to int32 becomes int32 range min.
var INT32_MIN = - 2147483648 ;
var outOfRangeLo = ee . Number ( INT32_MIN - 12345 );
print ( 'Less than int32 min:' , outOfRangeLo );
var outOfRangeLoToInt32 = outOfRangeLo . toInt32 ();
print ( 'Less than int32 min cast to int32 becomes int32 min:' , outOfRangeLoToInt32 );
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# Cast a number to signed 32-bit integer: [-2147483648, 2147483647].
number = ee . Number ( 100 )
print ( 'Number:' , number . getInfo ())
int32_number = number . toInt32 ()
print ( 'Number cast to int32:' , int32_number . getInfo ())
"""Casting numbers to int32 that are outside of its range and precision can
modify the resulting value, note the behavior of the following scenarios.
"""
# A floating point number cast to int32 loses decimal precision.
float_number = ee . Number ( 1.7 )
print ( 'Floating point value:' , float_number . getInfo ())
float_to_int32 = float_number . toInt32 ()
print ( 'Floating point value cast to int32:' , float_to_int32 . getInfo ())
# A number greater than int32 range max cast to int32 becomes int32 range max.
INT32_MAX = 2147483647
out_of_range_hi = ee . Number ( INT32_MAX + 12345 )
print ( 'Greater than int32 max:' , out_of_range_hi . getInfo ())
out_of_range_hi_to_int32 = out_of_range_hi . toInt32 ()
print ( 'Greater than int32 max cast to int32 becomes int32 max:' ,
out_of_range_hi_to_int32 . getInfo ())
# A number greater than int32 range min cast to int32 becomes int32 range min.
INT32_MIN = - 2147483648
out_of_range_lo = ee . Number ( INT32_MIN - 12345 )
print ( 'Less than int32 min:' , out_of_range_lo . getInfo ())
out_of_range_lo_to_int32 = out_of_range_lo . toInt32 ()
print ( 'Less than int32 min cast to int32 becomes int32 min:' ,
out_of_range_lo_to_int32 . getInfo ())
ส่งความคิดเห็น
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
หากต้องการบอกให้เราทราบเพิ่มเติม
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-26 UTC"],[],["The `toInt32()` method casts a number to a signed 32-bit integer, with a range from -2147483648 to 2147483647. Floating-point numbers lose decimal precision when cast. Numbers exceeding the maximum range become the maximum value, while numbers below the minimum range become the minimum value. It accepts an `input` value of type `Number` and returns a `Number` representing the signed 32-bit integer.\n"]]