exp(3M) DG/UX 5.4R3.00 exp(3M)
NAME
exp, expf, cbrt, log, logf, log10, log10f, pow, powf, sqrt, sqrtf -
exponential, logarithm, power, square root functions
SYNOPSIS
cc [flag ...] file ... -lm [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 non-negative. 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.
Those functions using float arguments, expf, logf, log10f, powf, and
sqrtf will give unpredictable results when used with the -Xt (which
is the default) compilation option. In traditional compilation mode
float arguments are promoted to doubles. An object compiled with -Xt
will expect this promotion and therefore not work correctly with
these functions.
Licensed material--property of copyright holder(s) 1
exp(3M) DG/UX 5.4R3.00 exp(3M)
Considerations for Threads Programming
+---------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+---------+-----------------------------+
|cbrt | Y N N |
|exp | Y N N |
|expf | Y N N |
|log | Y N N |
|log10 | Y N N |
|log10f | Y N N |
|logf | Y N N |
|pow | Y N N |
|powf | Y N N |
|sqrt | Y N N |
|sqrtf | Y N N |
+---------+-----------------------------+
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 using traditional ELF and COFF environments. In non-traditional
ELF environments (built without -Xt) no 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, HUGEVAL 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 -HUGEVAL and set errno to EDOM.
Under -Xc, log and logf return -HUGEVAL and set errno to ERANGE when
x is 0. Under -Xc, sqrt and sqrtf return NaN when x is negative.
NOTES
The X/Open (XPG) standard requires that pow with both x and y equal 0
be not treated as an error and 1.0 is returned. Since this behavior
conflicts with other standards which treat this case as an error, the
XPG behavior is only provided by libxpg. If you wish for the XPG
version include -lxpg on your link line before -lm.
Licensed material--property of copyright holder(s) 2
exp(3M) DG/UX 5.4R3.00 exp(3M)
SEE ALSO
cc(1), reentrant(3), hypot(3M), matherr(3M), sinh(3M).
Licensed material--property of copyright holder(s) 3