gmp_lib.mpn_divmod_1 Method

GMP Native Interface for .NET

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
)
Public Shared Function mpn_divmod_1 ( 
	r1p As mp_ptr,
	s2p As mp_ptr,
	s2n As mp_size_t,
	s3limb As mp_limb_t
) As mp_limb_t
public:
static mp_limb_t mpn_divmod_1(
	mp_ptr^ r1p, 
	mp_ptr^ s2p, 
	mp_size_t s2n, 
	mp_limb_t s3limb
)
static member mpn_divmod_1 : 
        r1p : mp_ptr * 
        s2p : mp_ptr * 
        s2n : mp_size_t * 
        s3limb : mp_limb_t -> mp_limb_t 

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

' Set r1p = s2p / 19.
Dim remainder As mp_limb_t = gmp_lib.mpn_divmod_1(r1p, s2p, s2p.Size, &H13)

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

' Release unmanaged memory.
gmp_lib.free(r1p, s2p, 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