mathscalbn 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 scalbn(
double number,
int exponent
)
Public Shared Function scalbn (
number As Double,
exponent As Integer
) As Double
public:
static double scalbn(
double number,
int exponent
)
static member scalbn :
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 scalbn(Double, Int32) is equivalent to ldexp(Double, Int32).
See scalbn in the C standard documentation.
ExamplesAssert.IsTrue(math.scalbn(0.8D, 4) == 12.8D);
Assert.IsTrue(math.scalbn(-0.854375D, 5) == -27.34D);
Assert.IsTrue(math.scalbn(1D, 0) == 1D);
Assert.IsTrue(math.scalbn(math.DBL_MIN / 2D, 0) == math.DBL_MIN / 2D);
Assert.IsTrue(math.scalbn(math.DBL_MIN / 2D, 1) == math.DBL_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS) == 2D * math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS - 1) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS - 1) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(1D, System.Int32.MaxValue) == System.Double.PositiveInfinity);
Assert.IsTrue(math.scalbn(1D, System.Int32.MinValue) == 0D);
Assert.IsTrue(math.scalbn(-1D, System.Int32.MaxValue) == System.Double.NegativeInfinity);
Assert.IsTrue(math.scalbn(-1D, System.Int32.MinValue) == -0D);
Assert.IsTrue(math.scalbn(0.8D, 4) = 12.8D);
Assert.IsTrue(math.scalbn(-0.854375D, 5) = -27.34D);
Assert.IsTrue(math.scalbn(1D, 0) = 1D);
Assert.IsTrue(math.scalbn(math.DBL_MIN / 2D, 0) = math.DBL_MIN / 2D);
Assert.IsTrue(math.scalbn(math.DBL_MIN / 2D, 1) = math.DBL_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS) = 2D * math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.5D, -math.DBL_MANT_BITS - 1) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(math.DBL_MIN * 1.25D, -math.DBL_MANT_BITS - 1) = math.DBL_DENORM_MIN);
Assert.IsTrue(math.scalbn(1D, System.Int32.MaxValue) = System.Double.PositiveInfinity);
Assert.IsTrue(math.scalbn(1D, System.Int32.MinValue) = 0D);
Assert.IsTrue(math.scalbn(-1D, System.Int32.MaxValue) = System.Double.NegativeInfinity);
Assert.IsTrue(math.scalbn(-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