Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Logarithmic Functions


frexp

You can use the frexp function to find out the values of a floating-point number's fraction field and exponent field.

double_t frexp (double_t x, int *exponent);
x
Any floating-point number.
exponent
A pointer to an integer in which the value of the exponent can be returned.
DESCRIPTION
The frexp function splits its first argument into a fraction part and a base 2 exponent part. This is an ANSI standard C library function.

frexp(x,n) = f such that x = f×2n

or

frexp(x,n) = f such that n = (1+logb(x)) and f = scalb(x,-n)

The return value of frexp is the value of the fraction field of the argument x. The exponent field of x is stored in the address pointed to by the exponent argument.

For finite nonzero inputs, frexp returns either 0.0 or a value whose magnitude is between 0.5 and 1.0.

The ldexp and scalb functions perform the inverse operation (compute f×2n ).

EXCEPTIONS
If x is finite and nonzero, the result of frexp(x,n) is exact.

SPECIAL CASES
Table 10-13 shows the results when the input argument to the frexp function is a zero, a NaN, or an Infinity.
Special cases for the frexp function
OperationResultExceptions raised
frexp(+0,n) +0 (n = 0)None
frexp(-0,n) -0 (n = 0)None
frexp(NaN,n) NaN (n is undefined)None[34]
frexp(+ ,n) + (n is undefined)None
frexp(- ,n) - (n is undefined)None

EXAMPLES
z = frexp(2E300, n);    /* z  0.746611 and n = 998. In other
                           words, 2  10300  0.746611  2998. */

[34] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996