gmp_lib.mpz_scan1 Method

GMP Native Interface for .NET

gmp_libmpz_scan1 Method
Scan op for 1 bit.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static mp_bitcnt_t mpz_scan1(
	mpz_t op,
	mp_bitcnt_t starting_bit
)
Public Shared Function mpz_scan1 ( 
	op As mpz_t,
	starting_bit As mp_bitcnt_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_scan1(
	mpz_t^ op, 
	mp_bitcnt_t starting_bit
)
static member mpz_scan1 : 
        op : mpz_t * 
        starting_bit : mp_bitcnt_t -> mp_bitcnt_t 

Parameters

op
Type: Math.Gmp.Nativempz_t
The operand integer.
starting_bit
Type: Math.Gmp.Nativemp_bitcnt_t
The start bit index position.

Return Value

Type: mp_bitcnt_t
Return the index of the found bit.
Remarks

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.

Examples
// 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);
' Create, initialize, and set the value of op to 70.
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 70UI)

' Assert that the first 1 bit starting from bit 3 in op is bit 6.
Assert.IsTrue(gmp_lib.mpz_scan1(op, 3UI) = 6UI)

' Release unmanaged memory allocated for op.
gmp_lib.mpz_clear(op)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also