gmp_lib.mpz_fdiv_q_ui Method

GMP Native Interface for .NET

gmp_libmpz_fdiv_q_ui Method
Set the quotient q to floor(n / d), and return the remainder r = | n - q * d |.

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 long mpz_fdiv_q_ui(
	mpz_t q,
	mpz_t n,
	uint d
)
Public Shared Function mpz_fdiv_q_ui ( 
	q As mpz_t,
	n As mpz_t,
	d As UInteger
) As Long
public:
static long long mpz_fdiv_q_ui(
	mpz_t^ q, 
	mpz_t^ n, 
	unsigned int d
)
static member mpz_fdiv_q_ui : 
        q : mpz_t * 
        n : mpz_t * 
        d : uint32 -> int64 

Parameters

q
Type: Math.Gmp.Nativempz_t
The result quotient integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: SystemUInt32
The denominator integer.

Return Value

Type: Int64
Return the remainder r = | n - q * d |.
Examples
// Create, initialize, and set the value of n to 10000.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 10000);

// Create, initialize, and set the value of q to 0.
mpz_t q = new mpz_t();
gmp_lib.mpz_init(q);

// Set q = floor(n / 3) and return r = n - 3 * q.
// Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3U) == 1U);
Assert.IsTrue(gmp_lib.mpz_get_si(q) == 3333);

// Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, null);
' Create, initialize, and set the value of n to 10000.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 10000)

' Create, initialize, and set the value of q to 0.
Dim q As New mpz_t()
gmp_lib.mpz_init(q)

' Set q = floor(n / 3) and return r = n - 3 * q.
' Assert q and r values.
Assert.IsTrue(gmp_lib.mpz_fdiv_q_ui(q, n, 3UI) = 1UI)
Assert.IsTrue(gmp_lib.mpz_get_si(q) = 3333)

' Release unmanaged memory allocated for n and q.
gmp_lib.mpz_clears(n, q, Nothing)

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