# Pfx.undigits

You're seeing just the function

`undigits`

, go back to Pfx module for more information.
## Specs

undigits({tuple(), pos_integer()}, pos_integer()) :: t()

Returns the prefix represented by the `digits`

, actual `length`

and a given
field `width`

.

The `pfx.bits`

are formed by first concatenating the `digits`

expressed as
bitstrings of `width`

-bits wide and then truncating to `length`

bits.

The `pfx.maxlen`

is inferred as `tuple_size(digits) * width`

.

Note: if a digit does not fit in `width`

-bits, only the `width`

-least
significant bits are preserved, which may yield surprising results.

## Examples

```
# truncated to the first 24 bits and maxlen is 32 (4*8)
iex> undigits({{10, 11, 12, 0}, 24}, 8)
%Pfx{bits: <<10, 11, 12>>, maxlen: 32}
iex> undigits({{-1, -1, 0, 0}, 32}, 8) |> format()
"255.255.0.0"
# bits are truncated to empty bitstring (`length` is 0)
iex> undigits({{1,2,3,4}, 0}, 8)
%Pfx{bits: <<>>, maxlen: 32}
# 32 4-bit wide numbers turn into an IPv6 prefix, truncated to 32 bits
# and maxlen is set to 32 * 4 = 128
iex> undigits({{1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 32},4)
%Pfx{bits: <<0x12, 0x34, 0x56, 0x78>>, maxlen: 128}
```