gmp_lib.mpz_mod Method

GMP Native Interface for .NET

gmp_libmpz_mod Method
Set r to n mod 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 void mpz_mod(
	mpz_t r,
	mpz_t n,
	mpz_t d
)
Public Shared Sub mpz_mod ( 
	r As mpz_t,
	n As mpz_t,
	d As mpz_t
)
public:
static void mpz_mod(
	mpz_t^ r, 
	mpz_t^ n, 
	mpz_t^ d
)
static member mpz_mod : 
        r : mpz_t * 
        n : mpz_t * 
        d : mpz_t -> unit 

Parameters

r
Type: Math.Gmp.Nativempz_t
The result remainder integer.
n
Type: Math.Gmp.Nativempz_t
The numerator integer.
d
Type: Math.Gmp.Nativempz_t
The denominator integer.
Remarks

The sign of the divisor is ignored; the result is always non-negative.

Examples
// Create, initialize, and set the value of x to 12222.
mpz_t x = new mpz_t();
gmp_lib.mpz_init_set_ui(x, 12222U);

// Create, initialize, and set the value of y to 10000.
mpz_t y = new mpz_t();
gmp_lib.mpz_init_set_ui(y, 10000U);

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

// Set z = x mod y.
gmp_lib.mpz_mod(z, x, y);

// Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) == 12222 % 10000);

// Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, null);
' Create, initialize, and set the value of x to 12222.
Dim x As New mpz_t()
gmp_lib.mpz_init_set_ui(x, 12222UI)

' Create, initialize, and set the value of y to 10000.
Dim y As New mpz_t()
gmp_lib.mpz_init_set_ui(y, 10000UI)

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

' Set z = x mod y.
gmp_lib.mpz_mod(z, x, y)

' Assert that z is 12222 mod 10000.
Assert.IsTrue(gmp_lib.mpz_get_si(z) = 12222 Mod 10000)

' Release unmanaged memory allocated for x, y, and z.
gmp_lib.mpz_clears(x, y, z, 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