mathfrexp Method (Double, Int32) |
Decomposes the given floating-point number into a normalized fraction and an integral power of two.
Namespace:
C
Assembly:
C.math (in C.math.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static double frexp(
double number,
ref int exponent
)
Public Shared Function frexp (
number As Double,
ByRef exponent As Integer
) As Double
public:
static double frexp(
double number,
int% exponent
)
static member frexp :
number : float *
exponent : int byref -> float
Parameters
- number
- Type: SystemDouble
A floating-point number. - exponent
- Type: SystemInt32
Reference to an Int32 value to store the exponent to.
Return Value
Type:
DoubleA
fraction in the range
[0.5, 1) so that
number = fraction * 2^exponent.
Remarks
Special values are treated as follows.
- If number is ±0, it is returned, and 0 is returned in exponent.
- If number is infinite, it is returned, and an undefined value is returned in exponent.
- If number is NaN, it is returned, and an undefined value is returned in exponent.
The function frexp(Double, Int32), together with its dual, ldexp(Double, Int32),
can be used to manipulate the representation of a floating-point number without direct bit manipulations.
The relation of frexp(Double, Int32) to logb(Double) and scalbn(Double, Int32) is:
exponent = (number == 0) ? 0 : (int)(1 + logb(number))
fraction = scalbn(number, -exponent)
See frexp in the C standard documentation.
ExamplesAssert.IsTrue(math.frexp(12.8D, ref exponent) = 0.8D);
Assert.IsTrue(exponent = 4);
Assert.IsTrue(math.frexp(0.25D, ref exponent) == 0.5D);
Assert.IsTrue(exponent == -1);
Assert.IsTrue(math.frexp(System.Math.Pow(2D, 1023), ref exponent) == 0.5D);
Assert.IsTrue(exponent == 1024);
Assert.IsTrue(math.frexp(-System.Math.Pow(2D, -1074), ref exponent) == -0.5D);
Assert.IsTrue(exponent == -1073);
Assert.IsTrue(math.frexp(12.8D, exponent) = 0.8D);
Assert.IsTrue(exponent = 4);
Assert.IsTrue(math.frexp(0.25D, exponent) = 0.5D);
Assert.IsTrue(exponent = -1);
Assert.IsTrue(math.frexp(System.Math.Pow(2D, 1023), exponent) = 0.5D);
Assert.IsTrue(exponent = 1024);
Assert.IsTrue(math.frexp(-System.Math.Pow(2D, -1074), exponent) = -0.5D);
Assert.IsTrue(exponent = -1073);
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