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 /


logb

You can use the logb function to determine the value in the exponent field of a floating-point number.

double_t logb (double_t x);
x
Any floating-point number.
DESCRIPTION
The logb function returns the signed exponent of its argument x as a signed integer value.

logb(x) = y such that x = f×2y

When the argument is a denormalized number, the exponent is determined as if the input argument had first been normalized.

Note that for a nonzero finite x, 1 fabs(scalb(x,-logb(x)))2 .

That is, for a nonzero finite x, the magnitude of x taken to the power of its inverse exponent is between 1 and 2.

This function conforms to IEEE Standard 854, which differs from IEEE Standard 754 on the treatment of a denormalized argument x.

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

SPECIAL CASES
Table 10-18 shows the results when the argument to the logb function is a zero, a NaN, or an Infinity.
Special cases for the logb function
OperationResultExceptions raised
logb(+0) - Divide-by-zero
logb(-0) - Divide-by-zero
logb(NaN) NaNNone[39]
logb(+ ) + None
logb(- ) + None

EXAMPLES
z = logb(789.9);  /* z = 9.0 because 789.9  1.54  29 */
z = logb(21456789);/* z = 24.0 because 21456789  1.28  224 */

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

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996