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 / Sign Manipulation Functions


fabs

You can use the fabs function to determine the absolute value of a real number.

double_t fabs (double_t x);
long double fabsl (long double x);
x
Any floating-point number.
DESCRIPTION
The fabs function returns the absolute value (positive value) of its argument.

fabs(x) = |x|

This function looks only at the sign bit, not the value, of its argument.

EXCEPTIONS
When x is finite and nonzero, the result of fabs(x) is exact.

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

EXAMPLES
z = fabs(-1.0);   /* z = 1 */
z = fabs(245.0);  /* z = 245 */

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

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996