bits shr

For bits.

Bitwise shift right for ints or binary values.

Command Type

built-in

Signature

> bits shr {flags} (bits)

Flags

  • --signed, -s: Always treat input number as a signed number.
  • --number-bytes, -n {int}: The word size in number of bytes. Must be 1, 2, 4, or 8 (defaults to 8).

Parameters

  • bits: Number of bits to shift right.

Input/output types:

input output
int int
binary binary
list<int> list<int>
list<binary> list<binary>

Examples

Shift right a number with 2 bits

> 8 | bits shr 2
2

Shift right a list of numbers

> [15 35 2] | bits shr 2
╭───┬───╮
│ 0 │ 3 │
│ 1 │ 8 │
│ 2 │ 0 │
╰───┴───╯

Shift right a binary value

> 0x[4f f4] | bits shr 4
Length: 2 (0x2) bytes | null_char printable whitespace ascii_other non_ascii
00000000:   04 ff                                                •×

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.