mathfrexp Method (Single, 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 float frexp(
float number,
ref int exponent
)
Public Shared Function frexp (
number As Single,
ByRef exponent As Integer
) As Single
public:
static float frexp(
float number,
int% exponent
)
static member frexp :
number : float32 *
exponent : int byref -> float32
Parameters
- number
- Type: SystemSingle
A floating-point number. - exponent
- Type: SystemInt32
Reference to an Int32 value to store the exponent to.
Return Value
Type:
SingleA
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(Single, Int32), together with its dual, ldexp(Single, Int32),
can be used to manipulate the representation of a floating-point number without direct bit manipulations.
The relation of frexp(Single, Int32) to logb(Single) and scalbn(Single, 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.8F, ref exponent) = 0.8F);
Assert.IsTrue(exponent = 4);
Assert.IsTrue(math.frexp(0.25F, ref exponent) == 0.5F);
Assert.IsTrue(exponent == -1);
Assert.IsTrue(math.frexp(System.Math.Pow(2F, 127F), ref exponent) == 0.5F);
Assert.IsTrue(exponent == 128);
Assert.IsTrue(math.frexp(-System.Math.Pow(2F, -149F), ref exponent) == -0.5F);
Assert.IsTrue(exponent == -148);
Assert.IsTrue(math.frexp(12.8F, exponent) = 0.8F);
Assert.IsTrue(exponent = 4);
Assert.IsTrue(math.frexp(0.25F, exponent) = 0.5F);
Assert.IsTrue(exponent = -1);
Assert.IsTrue(math.frexp(System.Math.Pow(2F, 127F), exponent) = 0.5F);
Assert.IsTrue(exponent = 128);
Assert.IsTrue(math.frexp(-System.Math.Pow(2F, -149F), exponent) = -0.5F);
Assert.IsTrue(exponent = -148);
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