gmp_libmpz_popcount Method |
Return the population count of op.
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_popcount(
mpz_t op
)
Public Shared Function mpz_popcount (
op As mpz_t
) As mp_bitcnt_t
public:
static mp_bitcnt_t mpz_popcount(
mpz_t^ op
)
static member mpz_popcount :
op : mpz_t -> mp_bitcnt_t
Parameters
- op
- Type: Math.Gmp.Nativempz_t
The operand integer.
Return Value
Type:
mp_bitcnt_tIf
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
mp_bitcnt_t.
Remarks
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
mpz_t op = new mpz_t();
gmp_lib.mpz_init_set_ui(op, 63U);
Assert.IsTrue(gmp_lib.mpz_popcount(op) == 6U);
gmp_lib.mpz_clears(op);
Dim op As New mpz_t()
gmp_lib.mpz_init_set_ui(op, 63UI)
Assert.IsTrue(gmp_lib.mpz_popcount(op) = 6UI)
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