Double-precision floating point (±1.7E±308, ~15 decimal digits)
1st Parameter
The input floating-point value to be decomposed
2nd Parameter Type : int *
A pointer to an integer, allowing indirect access to a variable of type `int`. Used to read or modify the value stored at the memory address it points to.
2nd Parameter
Pointer to an integer where the exponent part will be stored
Read more about parameters of frexp in parameters section
The frexpfunction in C language Decomposes a floating-point number into its binary significand and an integral exponent for 2.
The frexp function breaks a floating-point number x into a normalized fraction and an integral power of 2. It stores the integer exponent in the object pointed to by exp. The normalized fraction is returned as a double value, x, such that x is a double with magnitude in the interval [1/2, 1) or zero, and value = x * 2^(*exp). If value is zero, both parts of the result are zero.
The frexpfunction takes 2
parameters:
•
double `x`: The input floating-point value to be decomposed
•
int * `exp`: Pointer to an integer where the exponent part will be stored
Decomposes the floating-point number `x` into a normalized fraction and an integral power of 2. Returns the fraction as a `double` and stores the exponent in the integer pointed to by `exp`. The result satisfies the equation `x = fraction * 2^exp`.
The frexp function return value :
Returns the normalized fraction
If x is not zero, the normalized fraction is x times a power of two, and its absolute value is always in the range 1/2 (inclusive) to 1 (exclusive)
If x is zero, the function returns zero and stores zero in *exp
Output
This example demonstrates the basic usage of `frexp`. It decomposes a floating-point number into its fraction and exponent, then reconstructs the original number to verify the result.