Go forward to I/O of Integers.
Go backward to Comparison Functions.
Go up to Integer Functions.
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.