Click or drag to resize
gmp_libmpn_sec_div_r Method
Set R to N modulo D, where N = {np, nn}, D = {dp, dn}, and R = {np, dn}.

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_sec_div_r(
	mp_ptr np,
	mp_size_t nn,
	mp_ptr dp,
	mp_size_t dn,
	mp_ptr tp
)

Parameters

np
Type: Math.Gmp.Nativemp_ptr
The first operand and result integer.
nn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of np.
dp
Type: Math.Gmp.Nativemp_ptr
The second operand integer
dn
Type: Math.Gmp.Nativemp_size_t
The number of limbs of dp.
tp
Type: Math.Gmp.Nativemp_ptr
The scratch operand integer.
Remarks

It is required that nndn ≥ 1, and that dp[dn - 1] ≠ 0. This does not imply that N ≥ D since N might be zero-padded.

Note the overlapping between N and R. No other operand overlapping is allowed. The entire space occupied by N is overwritten.

This function requires scratch space of mpn_sec_div_r_itch(nn, dn) limbs to be passed in the tp parameter.

Examples
// Create multi-precision operands, and expected result.
mp_ptr np = new mp_ptr(new uint[] { 0xffffffff, 0x0000ffff });
mp_ptr dp = new mp_ptr(new uint[] { 0x00000004 });

// Create scratch space.
mp_size_t size = gmp_lib.mpn_sec_div_r_itch(np.Size, dp.Size);
mp_ptr tp = new mp_ptr(size);

// Set np = np mod dp.
gmp_lib.mpn_sec_div_r(np, np.Size, dp, dp.Size, tp);

// Assert result of operation.
Assert.IsTrue(np[0] == 3);

// Release unmanaged memory.
gmp_lib.free(np, dp, tp);
See Also