GMP Native Interface for .NET
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)

public static double mpf_get_d_2exp( ptr<int> exp, mpf_t op )
Public Shared Function mpf_get_d_2exp ( exp As ptr(Of Integer), op As mpf_t ) As Double
public: static double mpf_get_d_2exp( ptr<int>^ exp, mpf_t^ op )
static member mpf_get_d_2exp : exp : ptr<int> * op : mpf_t -> float
Parameters
- exp
- Type: Math.Gmp.NativeptrInt32
Pointer to 32-bit signed integer. - op
- Type: Math.Gmp.Nativempf_t
The operand float.
Return Value
Type: DoubleThe 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.

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

// 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);
' Set default precision to 64 bits. gmp_lib.mpf_set_default_prec(64UI) ' Create, initialize, and set a new floating-point number to -8.0 Dim x As 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. Dim exp As New ptr(Of Integer)(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)
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.
