These functions behave as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.

— Function: void **mpz_and** (`mpz_t rop, const mpz_t op1, const mpz_t op2`)

Set

roptoop1bitwise-andop2.

— Function: void **mpz_ior** (`mpz_t rop, const mpz_t op1, const mpz_t op2`)

Set

roptoop1bitwise inclusive-orop2.

— Function: void **mpz_xor** (`mpz_t rop, const mpz_t op1, const mpz_t op2`)

Set

roptoop1bitwise exclusive-orop2.

— Function: mp_bitcnt_t **mpz_popcount** (`const mpz_t op`)

If

op>=0, return the population count ofop, which is the number of 1 bits in the binary representation. Ifop<0, the number of 1s is infinite, and the return value is the largest possible`mp_bitcnt_t`

.

— Function: mp_bitcnt_t **mpz_hamdist** (`const mpz_t op1, const mpz_t op2`)

If

op1andop2are both >=0 or both <0, return the hamming distance between the two operands, which is the number of bit positions whereop1andop2have different bit values. If one operand is >=0 and the other <0 then the number of bits different is infinite, and the return value is the largest possible`mp_bitcnt_t`

.

— Function: mp_bitcnt_t **mpz_scan0** (`const mpz_t op, mp_bitcnt_t starting_bit`)

— Function: mp_bitcnt_t**mpz_scan1** (`const mpz_t op, mp_bitcnt_t starting_bit`)

— Function: mp_bitcnt_t

Scan

op, starting from bitstarting_bit, towards more significant bits, until the first 0 or 1 bit (respectively) is found. Return the index of the found bit.If the bit at

starting_bitis already what's sought, thenstarting_bitis returned.If there's no bit found, then the largest possible

`mp_bitcnt_t`

is returned. This will happen in`mpz_scan0`

past the end of a negative number, or`mpz_scan1`

past the end of a nonnegative number.