FLINT3.7.0-dev

fmpz_bit_pack, fmpz_bit_unpack, fmpz_bit_unpack_unsigned

Synopsis#include <flint/fmpz.h>
int fmpz_bit_pack(nn_ptr arr, flint_bitcnt_t shift, flint_bitcnt_t bits, const fmpz_t coeff, int negate, int borrow)source
int fmpz_bit_unpack(fmpz_t coeff, nn_srcptr arr, flint_bitcnt_t shift, flint_bitcnt_t bits, int negate, int borrow)source
void fmpz_bit_unpack_unsigned(fmpz_t coeff, nn_srcptr arr, flint_bitcnt_t shift, flint_bitcnt_t bits)source

Pack an integer into, respectively extract it from, a field of bits bits starting at bit shift <\mathtt{FLINT\_BITS} of the limb array arr. Signed fields are stored in two's complement with a borrow that propagates to the next field. These are the building blocks of Kronecker substitution in fmpz_poly.

fmpz_bit_pack adds coeff (negated first if negate is -1, minus borrow \in \{0, 1\}) to the field, assuming that the bits of arr from position shift on are zero. It returns 1 if the packed value is negative, which is the borrow to pass when packing the next field.

fmpz_bit_unpack sets coeff to the field, read as a signed value of bits bits, plus borrow, negated if negate is -1, and returns 1 if the field was negative, which is the borrow to add to the next field. fmpz_bit_unpack_unsigned reads the field as an unsigned value.

Cite this page

The FLINT team, “fmpz_bit_pack, fmpz_bit_unpack, fmpz_bit_unpack_unsigned (fmpz.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/fmpz/fmpz_bit_pack.html (generated 2026-10-20).