Skip to content

daft.functions.shift_right#

shift_right #

shift_right(expr: Expression, num_bits: Expression) -> Expression

Shifts the bits of an integer expression to the right (expr >> num_bits).

Parameters:

Name Type Description Default
expr Expression

The expression to shift.

required
num_bits Expression

The number of bits to shift the expression to the right

required
Note

For unsigned integers, this expression perform a logical right shift. For signed integers, this expression perform an arithmetic right shift.

Source code in daft/functions/bitwise.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def shift_right(expr: Expression, num_bits: Expression) -> Expression:
    """Shifts the bits of an integer expression to the right (``expr >> num_bits``).

    Args:
        expr: The expression to shift.
        num_bits: The number of bits to shift the expression to the right

    Note:
        For unsigned integers, this expression perform a logical right shift.
        For signed integers, this expression perform an arithmetic right shift.
    """
    expr = Expression._to_expression(expr)
    num_bits = Expression._to_expression(num_bits)
    return Expression._from_pyexpr(expr._expr >> num_bits._expr)