Click or drag to resize
gmp_libmpn_hamdist Method
Compute the hamming distance between {s1p, n} and {s2p, n}, which is the number of bit positions where the two operands have different bit values.

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 mpn_hamdist(
	mp_ptr s1p,
	mp_ptr s2p,
	mp_size_t n
)

Parameters

s1p
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
s2p
Type: Math.Gmp.Nativemp_ptr
The second operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs of s1p and s2p.

Return Value

Type: mp_bitcnt_t
The hamming distance between {s1p, n} and {s2p.
Examples
// Create multi-precision operands.
mp_ptr s1p = new mp_ptr(new uint[] { 0xffffffff, 0xffffffff });
mp_ptr s2p = new mp_ptr(new uint[] { 0x00000001, 0xffffffff });

// Assert hamming distance.
Assert.IsTrue(gmp_lib.mpn_hamdist(s1p, s2p, s1p.Size) == 31);

// Release unmanaged memory.
gmp_lib.free(s1p, s2p);
See Also