gmp_libmpf_swap Method |
Namespace: Math.Gmp.Native
public static void mpf_swap( mpf_t rop1, mpf_t rop2 )
Public Shared Sub mpf_swap ( rop1 As mpf_t, rop2 As mpf_t )
public: static void mpf_swap( mpf_t^ rop1, mpf_t^ rop2 )
static member mpf_swap : rop1 : mpf_t * rop2 : mpf_t -> unit
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);
' Create, initialize, and set a new floating-point number x to 10. Dim x As New mpf_t() gmp_lib.mpf_init2(x, 128UI) gmp_lib.mpf_set_si(x, 10) ' Create, initialize, and set a new floating-point number y to -210. Dim y As New mpf_t() gmp_lib.mpf_init2(y, 128UI) 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, 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.