Click or drag to resize
gmp_libmpf_get_d_2exp Method
Convert op to a double, truncating if necessary (i.e. rounding towards zero), and with an exponent returned 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 mpf_get_d_2exp(
	ptr<int> exp,
	mpf_t op
)

Parameters

exp
Type: Math.Gmp.NativeptrInt32
Pointer to 32-bit signed integer.
op
Type: Math.Gmp.Nativempf_t
The operand float.

Return Value

Type: Double
The return value is in the range 0.5 ≤ | d | < 1 and the exponent is stored at exp. d * 2^exp is the (truncated) op value. If op is zero, the return is 0.0 and 0 is stored at exp.
Remarks

This is similar to the standard C frexp function (see GNU C - Normalization Functions in The GNU C Library Reference Manual).

Examples
// Set default precision to 64 bits.
gmp_lib.mpf_set_default_prec(64U);

// Create, initialize, and set a new floating-point number to -8.0
mpf_t x = new mpf_t();
gmp_lib.mpf_init_set_d(x, -8.0);

// Assert that the absolute value of x is 0.5 x 2^4.
ptr<int> exp = new ptr<int>(0);
Assert.IsTrue(gmp_lib.mpf_get_d_2exp(exp, x) == 0.5);
Assert.IsTrue(exp.Value == 4);

// Release unmanaged memory allocated for x and exp.
gmp_lib.mpf_clear(x);
See Also