gmp_libmpz_scan1 Method |
Namespace: Math.Gmp.Native
Scan op, starting from bit starting_bit, towards more significant bits, until the first 1 bit 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 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.
The function behaves as if twos complement arithmetic were used (although sign-magnitude is the actual implementation). The least significant bit is number 0.
// Create, initialize, and set the value of op to 70. mpz_t op = new mpz_t(); gmp_lib.mpz_init_set_ui(op, 70U); // Assert that the first 1 bit starting from bit 3 in op is bit 6. Assert.IsTrue(gmp_lib.mpz_scan1(op, 3U) == 6U); // Release unmanaged memory allocated for op. gmp_lib.mpz_clear(op);