Pfx.bsr
You're seeing just the function
bsr
, go back to Pfx module for more information.
Specs
Arithmetic shift right the pfx.bits
by n
positions.
A negative n
actually shifts to the left.
Note that the pfx.bits
stays stays the same.
Examples
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}
# mask get applied when creating a `Pfx`
iex> bsr("1.2.3.4/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, 3, 4}, 16}, 2)
{{0, 64, 0, 0}, 16}