gmp_libmpq_set_num Method |
Namespace: Math.Gmp.Native
public static void mpq_set_num( mpq_t rational, mpz_t numerator )
Public Shared Sub mpq_set_num ( rational As mpq_t, numerator As mpz_t )
public: static void mpq_set_num( mpq_t^ rational, mpz_t^ numerator )
static member mpq_set_num : rational : mpq_t * numerator : mpz_t -> unit
The function is equivalent to calling mpz_set with mpq_numref. Direct use of mpq_numref is recommended instead of this functions.
// 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 num = new mpz_t(); gmp_lib.mpz_init_set_ui(num, 5U); // Set the numerator of op. gmp_lib.mpq_set_num(op, num); // Assert that op is 5 / 3. Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3U) == 0); // Release unmanaged memory allocated for op and num. gmp_lib.mpq_clear(op); gmp_lib.mpz_clear(num);
' 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 num As New mpz_t() gmp_lib.mpz_init_set_ui(num, 5UI) ' Set the numerator of op. gmp_lib.mpq_set_num(op, num) ' Assert that op is 5 / 3. Assert.IsTrue(gmp_lib.mpq_cmp_si(op, 5, 3UI) = 0) ' Release unmanaged memory allocated for op and num. gmp_lib.mpq_clear(op) gmp_lib.mpz_clear(num)
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.