### 12.6 Bit manipulations

There are a couple of functions to get information on arbitrary bits in an MPI and to set or clear them:

Function: unsigned int gcry_mpi_get_nbits (gcry_mpi_t a) ¶

  Return the number of bits required to represent a.

Function: int gcry_mpi_test_bit (gcry_mpi_t a, unsigned int n) ¶

  Return true if bit number n (counting from 0) is set in a.

Function: void gcry_mpi_set_bit (gcry_mpi_t a, unsigned int n) ¶

  Set bit number n in a.

Function: void gcry_mpi_clear_bit (gcry_mpi_t a, unsigned int n) ¶

  Clear bit number n in a.

Function: void gcry_mpi_set_highbit (gcry_mpi_t a, unsigned int n) ¶

  Set bit number n in a and clear all bits greater than n.

Function: void gcry_mpi_clear_highbit (gcry_mpi_t a, unsigned int n) ¶

  Clear bit number n in a and all bits greater than n.

Function: void gcry_mpi_rshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n) ¶

  Shift the value of a by n bits to the right and store the result in x.

Function: void gcry_mpi_lshift (gcry_mpi_t x, gcry_mpi_t a, unsigned int n) ¶

  Shift the value of a by n bits to the left and store the result in x.