Skip to content

Latest commit

 

History

History
90 lines (68 loc) · 2.12 KB

bits_and.md

File metadata and controls

90 lines (68 loc) · 2.12 KB
title categories version bits usage feature
bits and
bits
0.93.0
Performs bitwise and for ints or binary values.
Performs bitwise and for ints or binary values.
default

bits and for bits

Performs bitwise and for ints or binary values.

Signature

> bits and {flags} (target)

Flags

  • --endian, -e {string}: byte encode endian, available options: native(default), little, big

Parameters

  • target: right-hand side of the operation

Input/output types:

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

Examples

Apply bitwise and to two numbers

> 2 | bits and 2
2

Apply bitwise and to two binary values

> 0x[ab cd] | bits and 0x[99 99]
Length: 2 (0x2) bytes | printable whitespace ascii_other non_ascii
00000000:   89 89                                                ××

Apply bitwise and to a list of numbers

> [4 3 2] | bits and 2
╭───┬───╮
│ 00 │
│ 12 │
│ 22 │
╰───┴───╯

Apply bitwise and to a list of binary data

> [0x[7f ff] 0x[ff f0]] | bits and 0x[99 99]
╭───┬────────────╮
│ 0 │ [25, 153]  │
│ 1 │ [153, 144] │
╰───┴────────────╯

Apply bitwise and to binary data of varying lengths with specified endianness

> 0x[c0 ff ee] | bits and 0x[ff] --endian big
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   00 00 ee                                             00×

Apply bitwise and to input binary data smaller than the operand

> 0x[ff] | bits and 0x[12 34 56] --endian little
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   12 00 0000