gmp_lib.mpn_divexact_1 Method

GMP Native Interface for .NET

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
)
Public Shared Sub mpn_divexact_1 ( 
	rp As mp_ptr,
	sp As mp_ptr,
	n As mp_size_t,
	d As mp_limb_t
)
public:
static void mpn_divexact_1(
	mp_ptr^ rp, 
	mp_ptr^ sp, 
	mp_size_t n, 
	mp_limb_t d
)
static member mpn_divexact_1 : 
        rp : mp_ptr * 
        sp : mp_ptr * 
        n : mp_size_t * 
        d : mp_limb_t -> unit 

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);
' Create multi-precision operands, and expected result.
Dim sp As New mp_ptr(New UInteger() { &HffffffffUI, &Hffff})
Dim rp As New mp_ptr(New UInteger(1) { })
Dim result As New mp_ptr(New UInteger() { &H55555555, &H5555})

' Set rp = sp / 3.
gmp_lib.mpn_divexact_1(rp, sp, sp.Size, &H3)

' Assert result of operation.
Assert.IsTrue(rp.SequenceEqual(result))

' Release unmanaged memory.
gmp_lib.free(rp, sp, result)

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