Go to the first, previous, next, last section, table of contents.


Logical and Bit Manipulation Functions

These functions behave as if two's complement arithmetic were used (although sign-magnitude is used by the actual implementation).

Function: void mpz_and (mpz_t rop, mpz_t op1, mpz_t op2)
Set rop to op1 logical-and op2.

Function: void mpz_ior (mpz_t rop, mpz_t op1, mpz_t op2)
Set rop to op1 inclusive-or op2.

Function: void mpz_com (mpz_t rop, mpz_t op)
Set rop to the one's complement of op.

Function: unsigned long int mpz_popcount (mpz_t op)
For non-negative numbers, return the population count of op. For negative numbers, return the largest possible value (MAX_ULONG).

Function: unsigned long int mpz_hamdist (mpz_t op1, mpz_t op2)
If op1 and op2 are both non-negative, return the hamming distance between the two operands. Otherwise, return the largest possible value (MAX_ULONG).

It is possible to extend this function to return a useful value when the operands are both negative, but the current implementation returns MAX_ULONG in this case. Do not depend on this behavior, since it will change in future versions of the library.

Function: unsigned long int mpz_scan0 (mpz_t op, unsigned long int starting_bit)
Scan op, starting with bit starting_bit, towards more significant bits, until the first clear bit is found. Return the index of the found bit.

Function: unsigned long int mpz_scan1 (mpz_t op, unsigned long int starting_bit)
Scan op, starting with bit starting_bit, towards more significant bits, until the first set bit is found. Return the index of the found bit.

Function: void mpz_setbit (mpz_t rop, unsigned long int bit_index)
Set bit bit_index in op1.

Function: void mpz_clrbit (mpz_t rop, unsigned long int bit_index)
Clear bit bit_index in op1.


Go to the first, previous, next, last section, table of contents.