(gmp.info.gz) Integer Logic and Bit Fiddling
Info Catalog
(gmp.info.gz) Integer Comparisons
(gmp.info.gz) Integer Functions
(gmp.info.gz) I/O of Integers
Logical and Bit Manipulation Functions
======================================
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, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise-and OP2.
- Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise inclusive-or OP2.
- Function: void mpz_xor (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise exclusive-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)
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 ULONG_MAX, the largest
possible `unsigned long'.
- Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2)
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 ULONG_MAX, the largest
possible `unsigned long'.
- Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int
STARTING_BIT)
- Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int
STARTING_BIT)
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 ULONG_MAX is returned. This will
happen in `mpz_scan0' past the end of a positive number, or
`mpz_scan1' past the end of a negative.
- Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX)
Set bit BIT_INDEX in ROP.
- Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX)
Clear bit BIT_INDEX in ROP.
- Function: void mpz_combit (mpz_t ROP, unsigned long int BIT_INDEX)
Complement bit BIT_INDEX in ROP.
- Function: int mpz_tstbit (mpz_t OP, unsigned long int BIT_INDEX)
Test bit BIT_INDEX in OP and return 0 or 1 accordingly.
Info Catalog
(gmp.info.gz) Integer Comparisons
(gmp.info.gz) Integer Functions
(gmp.info.gz) I/O of Integers
automatically generated byinfo2html