Click or drag to resize
gmp_libmpn_divmod_1 Method
Divide {s2p, s2n} by s3limb, and write the quotient at r1p.

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_limb_t mpn_divmod_1(
	mp_ptr r1p,
	mp_ptr s2p,
	mp_size_t s2n,
	mp_limb_t s3limb
)

Parameters

r1p
Type: Math.Gmp.Nativemp_ptr
s2p
Type: Math.Gmp.Nativemp_ptr
s2n
Type: Math.Gmp.Nativemp_size_t
s3limb
Type: Math.Gmp.Nativemp_limb_t

Return Value

Type: mp_limb_t
Return the remainder.
Remarks

The integer quotient is written to {r1p, s2n}. s2n can be zero.

mpn_divmod_1 exists for upward source compatibility and is simply a macro calling mpn_divrem_1 with a qxn of 0.

The areas at r1p and s2p have to be identical or completely separate, not partially overlapping.

Examples
// Create multi-precision operands, and expected result.
mp_ptr s2p = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr r1p = new mp_ptr(new uint[2]);
mp_ptr result = new mp_ptr(new uint[] { 0x435e50d7, 0x00000d79 });

// Set r1p = s2p / 19.
mp_limb_t remainder = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, 0x13);

// Assert result of operation.
Assert.IsTrue(remainder == 10);
Assert.IsTrue(r1p.SequenceEqual(result));

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