Skip to content

Evaluate the number least-significant unset bits before seeing a set bit.

Description

Evaluate the number least-significant unset bits before seeing a set bit.

Usage

<Expr>$bitwise_trailing_zeros()

Value

A polars expression

Examples

library("polars")

df <- pl$DataFrame(n = c(-1L, 0L, 2L, 1L))
df$with_columns(trailing_zeros = pl$col("n")$bitwise_trailing_zeros())
#> shape: (4, 2)
#> ┌─────┬────────────────┐
#> │ n   ┆ trailing_zeros │
#> │ --- ┆ ---            │
#> │ i32 ┆ u32            │
#> ╞═════╪════════════════╡
#> │ -1  ┆ 0              │
#> │ 0   ┆ 32             │
#> │ 2   ┆ 1              │
#> │ 1   ┆ 0              │
#> └─────┴────────────────┘