Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.

ee.Number.signum

  • The signum function returns 0 if the input is 0, 1 if it's greater than 0, and -1 if it's less than 0.

  • TheNumber.signum() usage returns a Number.

  • The input value for thesignum function must be a Number.

Computes the signum function (sign) of the input; 0 if the input is 0, 1 if the input is greater than 0, -1 if the input is less than 0.

UsageReturns
Number.signum()Number
ArgumentTypeDetails
this:inputNumberThe input value.

Examples

Code Editor (JavaScript)

print('Sign of -5',ee.Number(-5).signum());// -1print('Sign of 0',ee.Number(0).signum());// 0print('Sign of 5',ee.Number(5).signum());// 1

Python setup

See the Python Environment page for information on the Python API and usinggeemap for interactive development.

importeeimportgeemap.coreasgeemap

Colab (Python)

display('Sign of -5:',ee.Number(-5).signum())# -1display('Sign of 0:',ee.Number(0).signum())# 0display('Sign of 5:',ee.Number(5).signum())# 1

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-07-13 UTC.