gmp_libmpf_swap Method |
Namespace: Math.Gmp.Native
Both the values and the precisions of the two variables are swapped.
// Create, initialize, and set a new floating-point number x to 10. mpf_t x = new mpf_t(); gmp_lib.mpf_init2(x, 128U); gmp_lib.mpf_set_si(x, 10); // Create, initialize, and set a new floating-point number y to -210. mpf_t y = new mpf_t(); gmp_lib.mpf_init2(y, 128U); gmp_lib.mpf_set_si(y, -210); // Swap the values of x and y. gmp_lib.mpf_swap(x, y); // Assert that the value of x is -210. Assert.IsTrue(gmp_lib.mpf_get_d(x) == -210.0); // Assert that the value of y is 10. Assert.IsTrue(gmp_lib.mpf_get_d(y) == 10.0); // Release unmanaged memory allocated for x and y. gmp_lib.mpf_clears(x, y, null);