Manual pages › Math library (3M)
exp(3M)
exponential, logarithm, power, square root functions
From the original Amiga UNIX 2.1 manual. Some things it mentions may not be in this release.
Also by this name: log(7), Devices and drivers
NAME
exp, expf, cbrt, log, logf, log10, log10f, pow, powf, sqrt, sqrtf - exponential, logarithm, power, square root functions
SYNOPSIS
cc [flag ...] file ... -lm [library ...] cc -O -Ksd [flag ...] file ... -J sfm [library ...] #include <math.h> double exp (double x); float expf (float x); double cbrt (double x); double log (double x); float logf (float x); double log10 (double x); float log10f (float x); double pow (double x, double y); float powf (float x, float y); double sqrt (double x); float sqrtf (float x);
DESCRIPTION
exp and expf return ex.
cbrt returns the cube root of x.
log and logf return the natural logarithm of x. The value of x must be positive.
log10 and log10f return the base ten logarithm of x. The value of x must be positive.
pow and powf return xy. If x is 0, y must be positive. If x is negative, y must be an integer.
sqrt and sqrtf return the non-negative square root of x. The value of x may not be negative.
SEE ALSO
hypot(3M), matherr(3M), sinh(3M).
DIAGNOSTICS
exp and expf return HUGE when the correct value would overflow, or 0 when the correct value would underflow, and set errno to ERANGE.
log, logf, log10, and log10f return -HUGE and set errno to EDOM when x is non-positive. A message indicating DOMAIN error is printed on standard error.
pow and powf return 0 and set errno to EDOM when x is 0 and y is non-positive, or when x is negative and y is not an integer. In these cases, a message indicating DOMAIN error is printed on standard error. When the correct value for pow or powf would overflow or underflow, these functions return +HUGE or 0, respectively, and set errno to ERANGE.
sqrt and sqrtf return 0 and set errno to EDOM when x is negative. A message indicating DOMAIN error is printed on standard error.
Except when the -Xc compilation option is used, these error-handling procedures may be changed with the function matherr. When the -Xa or -Xc compilation options are used, HUGE_VAL is returned instead of HUGE and no error messages are printed. In these compilation modes, pow and powf return 1, with no error, when both x and y are 0; when x is 0 and y is negative, they return -HUGE_VAL and set errno to EDOM. Under -Xc, log and logf return -HUGE_VAL and set errno to ERANGE when x is 0. Under -Xc, sqrt and sqrtf return NaN when x is negative.