Click or drag to resize
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)
Syntax
public static double scalbn(
	double number,
	int exponent
)

Parameters

number
Type: SystemDouble
A floating-point number.
exponent
Type: SystemInt32
The exponent of the power of two.

Return Value

Type: Double
The 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.

Examples
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);
See Also