Pfx.bsr
You're seeing just the function
bsr
, go back to Pfx module for more information.
Specs
Performs an arithmetic shift right the bits in pfx
by n
positions.
A negative n
actually shifts to the left. The length of the bits stays the
same.
Examples
iex> bsr("1.2.0.0/16", 2)
"0.64.0.0/16"
# no mask, so all 32 bits get shifted
iex> bsr({1, 2, 0, 0}, 2)
{0, 64, 128, 0}
iex> bsr({{1, 2, 0, 0}, 16}, 2)
{{0, 64, 0, 0}, 16}
iex> bsr(%Pfx{bits: <<1, 2>>, maxlen: 32}, 2)
%Pfx{bits: <<0, 64>>, maxlen: 32}
# now shift to the left
iex> bsr(%Pfx{bits: <<1, 2>>, maxlen: 32}, -2)
%Pfx{bits: <<4, 8>>, maxlen: 32}