Click or drag to resize
gmp_libmpz_get_d_2exp Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and returning the exponent separately.

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 double mpz_get_d_2exp(
	ref int exp,
	mpz_t op
)

Parameters

exp
Type: SystemInt32
The returned exponent.
op
Type: Math.Gmp.Nativempz_t
The integer.

Return Value

Type: Double
op as a double, truncating if necessary (i.e. rounding towards zero).
Remarks

The return value is in the range 0.5 ≤ | d | < 1 and the exponent is stored to exp. d x 2^exp is the (truncated) op value. If op is zero, the return value is 0.0 and 0 is stored to exp.

This is similar to the standard C frexp function.

Examples
// Create, initialize, and set the value of x to 2^20.
mpz_t x = new mpz_t();
char_ptr value = new char_ptr("100000000000000000000");
gmp_lib.mpz_init_set_str(x, value, 2);

// Assert that x is equal to 0.5^21.
int exp = 0;
Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D);
Assert.IsTrue(exp == 21);

// Release unmanaged memory allocated for x and the string value.
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
See Also