Function morton_encoding::arbitrary_bit_size::shrink_custom_biguint[][src]

pub fn shrink_custom_biguint(x: BigUint, siz_rat: NonZeroUsize) -> BigUint

“Shrinks” a given number from an arbitrarily large BigUint.

The 0th bit is always kept, as is every siz_ratth bit thereafter.

This function sanitises its input, such that the bits that are thrown away do not need to be cleared by the user. It is also assumed that the user will not need to use numbers larger than usize::max_value() bytes in size.

Unavailable if compiled with no_std.

Examples

assert_eq!(shrink_custom_biguint(tobuint(1u8), nz(2)), tobuint(1u8));
assert_eq!(shrink_custom_biguint(num::BigUint::new(vec!(3u32; 128)), nz(32)), num::BigUint::new(vec!(u32::max_value(); 4)));