exp(3M) DG/UX R4.11MU05 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 must be positive.
Those functions using float arguments, expf, logf, log10f, powf, and
sqrtf will give unpredictable results when used with the -Xt
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.
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.
When the -Xt compilation option is used, log, logf, log10, and log10f
return -HUGE and set errno to EDOM when x is negative. In addition,
a message indicating DOMAIN error is printed on the standard error
output. When x is zero, these routines return -HUGE and set errno to
EDOM. In addition, a message indicating SING error is printed on the
standard error output.
When the -Xa or -Xc compilation options are used, log, logf, log10,
and log10f return IEEE NaN, raise an invalid operation exception,
and set errno to EDOM when x is negative. When x is zero, these
routines return -HUGE-VAL, raise a divide by zero exception, and set
errno to EDOM.
When the -Xt compilation option is used, pow and powf return 0 and
set errno to EDOM when x is zero and y is negative, when x is
negative and y is not an integer, or when both x and y are zero. In
addition, a message indicating DOMAIN error is printed on standard
error.
When the -Xa or -Xc compilation options are used, pow and powf return
HUGE_VAL, raise a divide by zero exception, and set errno to EDOM
when x is zero and y is negative. When x is zero and y is a negative
odd integer, these routines return ±HUGE_VAL, depending upon the sign
of x , raise a divide by zero exception, and set errno to EDOM. When
x is zero and y is a negative even integer, pow and powf return
HUGE_VAL, raise a divide by zero exception, and set errno to EDOM.
When x is negative and y is not an integer, these routines return
IEEE NaN, raise an invalid operation exception, and set errno to
EDOM. When both x and y are zero, pow and powf return 1 with no
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.
When the -Xt compilation option is used, sqrt and sqrtf return 0 and
set errno to EDOM when x is negative. In addition, a message
indicating DOMAIN error is printed on standard error.
When the -Xa or -Xc compilation options are used, sqrt and sqrtf
return IEEE NaN, raise an invalid operation exception, and set errno
to EDOM when x is negative.
For each of these functions, if any argument is a quiet NaN, that
value is returned. If any argument is a signaling NaN, a quiet NaN
is returned and an invalid operation exception is raised. In either
case, errno is set to EDOM, and a message indicating DOMAIN error is
printed on the standard error output. The only exception is that pow
and powf return 1 when y is zero, regardless of the value of x
When the -Xt 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.
SEE ALSO
cc(1), reentrant(3), hypot(3M), matherr(3M), fpsetmask(3C), sinh(3M).
Licensed material--property of copyright holder(s)