ADC Home > Reference Library > Reference > Mac OS X > Mac OS X Man Pages

This document is a Mac OS X manual page. Manual pages are a commandline technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles. For more information about the manual page format, see the manual page for manpages(5). 
MATH(3) BSD Library Functions Manual MATH(3) NAME math  mathematical library functions SYNOPSIS #include <math.h> DESCRIPTION The header file math.h provides function prototypes and macros for working working ing with C99 floating point values. Each math.h function is provided in three variants: single, double and extended precision. The single and double precision variants operate on IEEE754 single and double precision values, which correspond to the C types float and double, respectively. On Intel Macs, the C type long double corresponds to 80bit IEEE754 double double ble extended precision. On PowerPC Macs, the C type long double corresponds corresponds sponds by default to ordinary double precision, but a 128bit nonIEEE754 nonIEEE754 IEEE754 long double type is also available via the compiler flag mlongdouble128 and linker flag lmx. Details of the floating point formats can be found via "man float". Users who need to repeatedly perform the same calculation on a large set of data will probably find that the vector math library (composed of vMathLib and vForce) yields better performance for their needs than sequential calls to the libm. Users who need to perform mathematical operations on complex floatingpoint floatingpoint point numbers should consult the man pages for the complex portion of the math library, via "man complex". LIST OF FUNCTIONS Each of the functions that use floatingpoint values are provided in single, single, gle, double, and extended precision; the double precision prototypes are listed here. The man pages for the individual functions provide more details on their use, special cases, and prototypes for their single and extended precision versions. int fpclassify(double) int isfinite(double) int isinf(double) int isnan(double) int isnormal(double) int signbit(double) These functionlike macros are used to classify a single floatingpoint argument. double copysign(double, double) double nextafter(double, double) copysign(x, y) returns the value equal in magnitude to x with the sign of y. nextafter(x, y) returns the next floatingpoint number after x in the direction of y. Both are correctlyrounded. double nan(const char *tag) The nan() function returns a quiet NaN, without raising the invalid flag. double ceil(double) double floor(double) double nearbyint(double) double rint(double) double round(double) long int lrint(double) long int lround(double) long long int llrint(double) long long int llround(double) double trunc(double) These functions provide various means to round floatingpoint values to integral values. They are correctly rounded. double fmod(double, double) double remainder(double, double) double remquo(double x, double y, int *) These return a remainder of the division of x by y with an integral quotient. quotient. tient. remquo() additionally provides access to a few lower bits of the quotient. They are correctly rounded. double fdim(double, double) double fmax(double, double) double fmin(double, double) fmax(x, y) and fmin(x, y) return the maximum and minimum of x and y, respectively. fdim(x, y) returns the positive difference of x and y. All are correctly rounded. double fma(double x, double y, double z) fma(x, y, z) computes the value (x*y) + z as though without intermediate rounding. It is correctly rounded. double fabs(double) double sqrt(double) double cbrt(double) double hypot(double, double) fabs(x), sqrt(x), and cbrt(x) return the absolute value, square root, and cube root of x, respectively. hypot(x, y) returns sqrt(x*x + y*y). fabs() and sqrt() are correctly rounded. double exp(double) double exp2(double) double expm1(double) exp(x), exp2(x), and expm1(x) return e**x, 2**x, and e**x  1, respectively. respectively. tively. double log(double) double log2(double) double log10(double) double log1p(double) log(x), log2(x), and log10(x) return the natural, base2, and base10 logarithms of x, respectively. log1p(x) returns the natural log of 1+x. double logb(double) int ilogb(double) logb(x) and ilogb(x) return the exponent of x. double modf(double, double *) double frexp(double, int *) modf(x, &y) returns the fractional part of x and stores the integral part in y. frexp(x, &n) returns the mantissa of x and stores the exponent in n. They are correctly rounded. double ldexp(double, int) double scalbn(double, int) double scalbln(double, long int) ldexp(x, n), scalbn(x, n), and scalbln(x, n) return x*2**n. They are correctly rounded. double pow(double, double) pow(x,y) returns x raised to the power y. double cos(double) double sin(double) double tan(double) cos(x), sin(x), and tan(x) return the cosine, sine and tangent of x, respectively. double cosh(double) double sinh(double) double tanh(double) cosh(x), sinh(x), and tanh(x) return the hyperbolic cosine, hyperbolic sine and hyperbolic tangent of x, respectively. double acos(double) double asin(double) double atan(double) double atan2(double, double) acos(x), asin(x), and atan(x) return the inverse cosine, inverse sine and inverse tangent of x, respectively. atan2(y, x) returns the inverse tangent tangent gent of y/x, with sign chosen according to the quadrant of (x,y). double acosh(double) double asinh(double) double atanh(double) acosh(x), asinh(x), and atanh(x) return the inverse hyperbolic cosine, inverse hyperbolic sine and inverse hyperbolic tangent of x, respectively. respectively. tively. double tgamma(double) double lgamma(double) tgamma(x) and lgamma(x) return the values of the gamma function and its logarithm evalutated at x, respectively. double j0(double) double j1(double) double jn(double) double y0(double) double y1(double) double yn(double) j0(x), j1(x), and jn(x) return the values of the zeroth, first, and nth Bessel function of the first kind evaluated at x, respectively. y0(x), y1(x), and yn(x) return the values of the zeroth, first, and nth Bessel function of the second kind evaluated at x, respectively. double erf(double) double erfc(double) erf(x) and erfc(x) return the values of the error function and the complementary complementary plementary error function evaluated at x, respectively. MATHEMATICAL CONSTANTS In addition to the functions listed above, math.h defines a number of useful constants, listed below. All are defined as C99 floatingpoint constants. CONSTANT VALUE M_E base of natural logarithm, e M_LOG2E log2(e) M_LOG10E log10(e) M_LN2 ln(2) M_LN10 ln(10) M_PI pi M_PI_2 pi / 2 M_PI_4 pi / 4 M_1_PI 1 / pi M_2_PI 2 / pi M_2_SQRTPI 2 / sqrt(pi) M_SQRT2 sqrt(2) M_SQRT1_2 sqrt(1/2) IEEE STANDARD 754 FLOATINGPOINT ARITHMETIC The libm functions declared in math.h provide mathematical library functions functions tions in single, double, and extendedprecision IEEE754 floatingpoint formats on Intel macs, and in single and doubleprecision IEEE754 floatingpoint formats on PowerPC macs. SEE ALSO float(3), complex(3) STANDARDS The <math.h> functions conform to the ISO/IEC 9899:1999(E) standard. BSD March 20, 2007 BSD 