mathldexp Method (Double, Int32) |
Scales the specified floating-point number by 2^exponent.
Namespace:
C
Assembly:
C.math (in C.math.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static double ldexp(
double number,
int exponent
)
Public Shared Function ldexp (
number As Double,
exponent As Integer
) As Double
public:
static double ldexp(
double number,
int exponent
)
static member ldexp :
number : float *
exponent : int -> float
Parameters
- number
- Type: SystemDouble
A floating-point number. - exponent
- Type: SystemInt32
The exponent of the power of two.
Return Value
Type:
DoubleThe value
number * 2^exponent.
Remarks
Special values are treated as follows.
- If number is ±0, it is returned.
- If number is infinite, it is returned.
- If exponent is 0, number is returned.
- If number is NaN, NaN is returned.
The function ldexp(Double, Int32) ("load exponent"), together with its dual, frexp(Double, Int32),
can be used to manipulate the representation of a floating-point number without direct bit manipulations.
The function ldexp(Double, Int32) is equivalent to scalbn(Double, Int32).
See ldexp in the C standard documentation.
ExamplesAssert.IsTrue(math.ldexp(0.8D, 4) == 12.8D);
Assert.IsTrue(math.ldexp(-0.854375D, 5) == -27.34D);
Assert.IsTrue(math.ldexp(1D, 0) == 1D);
Assert.IsTrue(math.ldexp(math.DBL_MIN / 2D, 0) == math.DBL_MIN / 2D);
Assert.IsTrue(math.ldexp(math.DBL_MIN / 2D, 1) == math.DBL_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS) == 2D * math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS - 1) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS - 1) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(1D, System.Int32.MaxValue) == System.Double.PositiveInfinity);
Assert.IsTrue(math.ldexp(1D, System.Int32.MinValue) == 0D);
Assert.IsTrue(math.ldexp(-1D, System.Int32.MaxValue) == System.Double.NegativeInfinity);
Assert.IsTrue(math.ldexp(-1D, System.Int32.MinValue) == -0D);
Assert.IsTrue(math.ldexp(0.8D, 4) = 12.8D);
Assert.IsTrue(math.ldexp(-0.854375D, 5) = -27.34D);
Assert.IsTrue(math.ldexp(1D, 0) = 1D);
Assert.IsTrue(math.ldexp(math.DBL_MIN / 2D, 0) = math.DBL_MIN / 2D);
Assert.IsTrue(math.ldexp(math.DBL_MIN / 2D, 1) = math.DBL_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS) = 2D * math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS - 1) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS - 1) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.ldexp(1D, System.Int32.MaxValue) = System.Double.PositiveInfinity);
Assert.IsTrue(math.ldexp(1D, System.Int32.MinValue) = 0D);
Assert.IsTrue(math.ldexp(-1D, System.Int32.MaxValue) = System.Double.NegativeInfinity);
Assert.IsTrue(math.ldexp(-1D, System.Int32.MinValue) = -0D);
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