gmp_lib.mpq_set_den Method

GMP Native Interface for .NET

gmp_libmpq_set_den Method
Set the denominator of rational to denominator.

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 mpq_set_den(
	mpq_t rational,
	mpz_t denominator
)
Public Shared Sub mpq_set_den ( 
	rational As mpq_t,
	denominator As mpz_t
)
public:
static void mpq_set_den(
	mpq_t^ rational, 
	mpz_t^ denominator
)
static member mpq_set_den : 
        rational : mpq_t * 
        denominator : mpz_t -> unit 

Parameters

rational
Type: Math.Gmp.Nativempq_t
The result rational.
denominator
Type: Math.Gmp.Nativempz_t
The operand integer.
Remarks
The function is equivalent to calling mpz_set with mpq_denref. Direct use of mpq_denref is recommended instead of this functions.
Examples
// Create, initialize, and set the value of op to -1 / 3.
mpq_t op = new mpq_t();
gmp_lib.mpq_init(op);
gmp_lib.mpq_set_si(op, -1, 3U);

// Create, initialize, and set the value of a new integer to 5.
mpz_t den = new mpz_t();
gmp_lib.mpz_init_set_ui(den, 5U);

// Set the denominator of op.
gmp_lib.mpq_set_den(op, den);

// Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5U) == 0);

// Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op);
gmp_lib.mpz_clear(den);
' Create, initialize, and set the value of op to -1 / 3.
Dim op As New mpq_t()
gmp_lib.mpq_init(op)
gmp_lib.mpq_set_si(op, -1, 3UI)

' Create, initialize, and set the value of a new integer to 5.
Dim den As New mpz_t()
gmp_lib.mpz_init_set_ui(den, 5UI)

' Set the denominator of op.
gmp_lib.mpq_set_den(op, den)

' Assert that op is -1 / 5.
Assert.IsTrue(gmp_lib.mpq_cmp_si(op, -1, 5UI) = 0)

' Release unmanaged memory allocated for op and num.
gmp_lib.mpq_clear(op)
gmp_lib.mpz_clear(den)

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