Click or drag to resize
gmp_libmpn_divexact_1 Method
Divide {sp, n} by d, expecting it to divide exactly, and writing the result to {rrp, n}.

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 void mpn_divexact_1(
	mp_ptr rp,
	mp_ptr sp,
	mp_size_t n,
	mp_limb_t d
)

Parameters

rp
Type: Math.Gmp.Nativemp_ptr
The result integer.
sp
Type: Math.Gmp.Nativemp_ptr
The first operand integer.
n
Type: Math.Gmp.Nativemp_size_t
The number of limbs in sp and rp.
d
Type: Math.Gmp.Nativemp_limb_t
The second operand integer.
Remarks

If d doesn’t divide exactly, the value written to {rp, n} is undefined. The areas at rp and sp have to be identical or completely separate, not partially overlapping.

Examples
// Create multi-precision operands, and expected result.
mp_ptr sp = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr rp = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x55555555, 0x00005555 });

// Set rp = sp / 3.
gmp_lib.mpn_divexact_1(rp, sp, sp.Size, 0x3);

// Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result));

// Release unmanaged memory.
gmp_lib.free(rp, sp, result);
See Also