maskBits

fnBigInt maskBits(BigInt n, size_t k) pure @safe

Masks the lower k bits of a BigInt (computes abs(n) & ((1<<k)-1)).

This is a helper function that extracts the lower k bits of the absolute value of n, effectively computing n mod 2^k for positive n.

Parameters

nThe value to mask
kThe number of bits to keep

Returns

The lower k bits of abs(n)