ee.Number.and
Returns 1 if and only if both values are non-zero.
Usage | Returns |
---|
Number.and(right) | Number |
Argument | Type | Details |
---|
this: left | Number | The left-hand value. |
right | Number | The right-hand value. |
Examples
print('Both 5 and 10 are not 0?', ee.Number(5).and(ee.Number(10))); // 1
print('Both 5 and 0 are not 0?', ee.Number(5).and(ee.Number(0))); // 0
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
# 1
print('Both 5 and 10 are not 0?', ee.Number(5).And(ee.Number(10)).getInfo())
# 0
print('Both 5 and 0 are not 0?', ee.Number(5).And(ee.Number(0)).getInfo())
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 2023-12-06 UTC.
[null,null,["Last updated 2023-12-06 UTC."],[[["The `and` function returns 1 if both input values are non-zero, and 0 otherwise, essentially acting as a logical 'AND' operator for numbers."],["It takes two arguments: a left-hand value (`left`) and a right-hand value (`right`), both of which should be numbers."],["You can access this function on an `ee.Number` object by using the `.and()` method in JavaScript or `.And()` in Python to perform a bitwise AND operation."]]],["The `Number.and()` method checks if two numerical values are non-zero. It takes a `right` numerical value as an argument and implicitly uses a `left` value. The method returns 1 if both the left and right values are non-zero; otherwise, it returns 0. Example code is provided in both JavaScript and Python to demonstrate the function's behavior with non-zero and zero inputs.\n"]]