gmp_libmpf_ui_div Method |
Namespace: Math.Gmp.Native
Division is undefined if the divisor is zero, and passing a zero divisor to the divide functions will make it intentionally divide by zero. This lets the user handle arithmetic exceptions in division functions in the same manner as other arithmetic exceptions.
// Set default precision to 64 bits. gmp_lib.mpf_set_default_prec(64U); // Create, initialize, and set a new floating-point number x to 10. mpf_t x = new mpf_t(); gmp_lib.mpf_init_set_si(x, 10); // Create and initialize a new floating-point number z. mpf_t z = new mpf_t(); gmp_lib.mpf_init(z); // Set z = 210 / x. gmp_lib.mpf_ui_div(z, 210U, x); // Assert that the value of z is 21. Assert.IsTrue(gmp_lib.mpf_get_d(z) == 21.0); // Release unmanaged memory allocated for x and z. gmp_lib.mpf_clears(x, z, null);