ee.Number.rightShift

  • The Number.rightShift(right) method calculates the signed right shift of a number (left) by a specified number of bits (right).

  • It takes two arguments, the left-hand value (this: left) and the right-hand value (right), both of which are Numbers.

  • The method returns a Number, representing the result of the signed right shift operation.

Calculates the signed right shift of v1 by v2 bits.

UsageReturns
Number.rightShift(right)Number
ArgumentTypeDetails
this: leftNumberThe left-hand value.
rightNumberThe right-hand value.

Examples

Code Editor (JavaScript)

/**
 * Unsigned 8-bit type example.
 *
 * 20 as binary:   00010100
 * Right shift 2:  00000101
 *
 * 00000101 is binary for 5.
 */

print(ee.Number(20).rightShift(2));  // 5

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)

"""Unsigned 8-bit type example.

20 as binary:   00010100
Right shift 2:  00000101

00000101 is binary for 5.
"""

print(ee.Number(20).rightShift(2).getInfo())  # 5