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
)
Public Shared Function mpz_get_d_2exp (
ByRef exp As Integer,
op As mpz_t
) As Double
public:
static double mpz_get_d_2exp(
int% exp,
mpz_t^ op
)
static member mpz_get_d_2exp :
exp : int byref *
op : mpz_t -> float
Parameters
- exp
- Type: SystemInt32
The returned exponent. - op
- Type: Math.Gmp.Nativempz_t
The integer.
Return Value
Type:
Doubleop 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
mpz_t x = new mpz_t();
char_ptr value = new char_ptr("100000000000000000000");
gmp_lib.mpz_init_set_str(x, value, 2);
int exp = 0;
Assert.IsTrue(gmp_lib.mpz_get_d_2exp(ref exp, x) == 0.5D);
Assert.IsTrue(exp == 21);
gmp_lib.mpz_clear(x);
gmp_lib.free(value);
Dim x As New mpz_t()
Dim value As New char_ptr("100000000000000000000")
gmp_lib.mpz_init_set_str(x, value, 2)
Dim exp As Integer = 0
Assert.IsTrue(gmp_lib.mpz_get_d_2exp(exp, x) = 0.5)
Assert.IsTrue(exp = 21)
gmp_lib.mpz_clear(x)
gmp_lib.free(value)
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.
See Also