unsigned_decomposition

Function unsigned_decomposition 

Source
pub fn unsigned_decomposition<const BASE: u64, const N: usize>(
    value: u64,
) -> Option<[u16; N]>
Expand description

Decompose a number into N digits in a given base, MSB first. Returns None iff the number is too large to fit in N digits.

§Requires:

  • log2(BASE) * N <= 64
  • BASE <= (1 << 16)

§Example

assert_eq!(unsigned_decomposition::<10, 3>(987), Some([9, 8, 7]));
assert_eq!(unsigned_decomposition::<10, 3>(9870), None);