mathldexp Method (Single, 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 float ldexp(
float number,
int exponent
)
Public Shared Function ldexp (
number As Single,
exponent As Integer
) As Single
public:
static float ldexp(
float number,
int exponent
)
static member ldexp :
number : float32 *
exponent : int -> float32
Parameters
- number
- Type: SystemSingle
A floating-point number. - exponent
- Type: SystemInt32
The exponent of the power of two.
Return Value
Type:
SingleThe 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(Single, Int32) ("load exponent"), together with its dual, frexp(Single, Int32),
can be used to manipulate the representation of a floating-point number without direct bit manipulations.
The function ldexp(Single, Int32) is equivalent to scalbn(Single, Int32).
See ldexp in the C standard documentation.
ExamplesAssert.IsTrue(math.ldexp(0.8F, 4) == 12.8F);
Assert.IsTrue(math.ldexp(-0.854375F, 5) == -27.34F);
Assert.IsTrue(math.ldexp(1F, 0) == 1F);
Assert.IsTrue(math.ldexp(math.FLT_MIN / 2F, 0) == math.FLT_MIN / 2F);
Assert.IsTrue(math.ldexp(math.FLT_MIN / 2F, 1) == math.FLT_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.5F, -math.FLT_MANT_BITS) == 2F * math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.5F, -math.FLT_MANT_BITS - 1) == math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.25F, -math.FLT_MANT_BITS) == math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.25F, -math.FLT_MANT_BITS - 1) == math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(1F, System.Int32.MaxValue) == System.Single.PositiveInfinity);
Assert.IsTrue(math.ldexp(1F, System.Int32.MinValue) == 0F);
Assert.IsTrue(math.ldexp(-1F, System.Int32.MaxValue) == System.Single.NegativeInfinity);
Assert.IsTrue(math.ldexp(-1F, System.Int32.MinValue) == -0F);
Assert.IsTrue(math.ldexp(0.8F, 4) = 12.8F);
Assert.IsTrue(math.ldexp(-0.854375F, 5) = -27.34F);
Assert.IsTrue(math.ldexp(1F, 0) = 1F);
Assert.IsTrue(math.ldexp(math.FLT_MIN / 2F, 0) = math.FLT_MIN / 2F);
Assert.IsTrue(math.ldexp(math.FLT_MIN / 2F, 1) = math.FLT_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.5F, -math.FLT_MANT_BITS) = 2F * math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.5F, -math.FLT_MANT_BITS - 1) = math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.25F, -math.FLT_MANT_BITS) = math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(math.FLT_MIN * 1.25F, -math.FLT_MANT_BITS - 1) = math.FLT_DENORM_MIN);
Assert.IsTrue(math.ldexp(1F, System.Int32.MaxValue) = System.Single.PositiveInfinity);
Assert.IsTrue(math.ldexp(1F, System.Int32.MinValue) = 0F);
Assert.IsTrue(math.ldexp(-1F, System.Int32.MaxValue) = System.Single.NegativeInfinity);
Assert.IsTrue(math.ldexp(-1F, System.Int32.MinValue) = -0F);
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