These functions behave as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.
Set rop to op1 bitwise-and op2.
Set rop to op1 bitwise inclusive-or op2.
Set rop to op1 bitwise exclusive-or op2.
Set rop to the one’s complement of op.
If op>=0, return the population count of op, which is the
number of 1 bits in the binary representation. If op<0, the
number of 1s is infinite, and the return value is the largest possible
If op1 and op2 are both >=0 or both <0, return the
hamming distance between the two operands, which is the number of bit positions
where op1 and op2 have 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
Scan op, starting from bit starting_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_bit is already what’s sought, then starting_bit is returned.
If there’s no bit found, then the largest possible
returned. This will happen in
mpz_scan0 past the end of a negative
mpz_scan1 past the end of a nonnegative number.
Set bit bit_index in rop.
Clear bit bit_index in rop.
Complement bit bit_index in rop.
Test bit bit_index in op and return 0 or 1 accordingly.