exp(3M) 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 zero, 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.
Errors
exp and expf return a value that will compare equal to
HUGE_VAL when the correct value would overflow, or zero when
the correct value would underflow, and set errno to ERANGE.
log, logf, log10, and log10f return a value that will compare
equal to -HUGE_VAL and set errno to ERANGE when x is zero. On
systems that support IEEE floating-point, the divide by zero
exception is raised.
Copyright 1994 Novell, Inc. Page 1
exp(3M) exp(3M)
If x is negative, log, logf, log10, and log10f return IEEE NaN
on systems that support it and raise the invalid operation
exception. Otherwise, they return zero and set errno to EDOM.
On systems that support IEEE NaN, if any of the inputs to each
of these functions is a quiet NaN, that value is returned. If
any input is a signaling NaN, a quiet NaN is returned and the
invalid operation exception is raised. In either case, errno
is set to EDOM. The only exceptions to this rule are for pow
and powf, which always return 1 when their second argument is
zero, regardless of the value of their first argument.
If x is negative and y is finite and nonintegral, pow and powf
return IEEE NaN on systems that support it and raise the
invalid operation exception. Otherwise, they return zero and
set errno to EDOM.
When x is zero and y is negative, finite and an odd integer,
pow and powf return a value that will compare equal to
_HUGE_VAL, according to the sign of x, (+HUGE_VAL, if -0 is
not supported). When x is zero and y is negative, finite and
not an odd integer, pow and powf return a value that will
compare equal to +HUGE_VAL. In each of these cases, errno is
set to EDOM. On systems that support IEEE exceptions, the
divide by zero exception is raised.
On systems that support IEEE infinity, when x is _1 and y is _
oo, pow and powf return IEEE NaN, raise the invalid operation
exception and set errno to EDOM.
When the correct value for pow or powf would overflow or
underflow, these functions return a value that will compare
equal to _HUGE_VAL or zero, respectively, and set errno to
ERANGE.
When x is negative, sqrt and sqrtf return IEEE NaN on systems
that support it and raise the invalid operation exception.
Otherwise, they return 0. errno is set to EDOM.
If the program was compiled with the -Xt compilation mode, a
value that will compare equal to _HUGE is returned instead of
_HUGE_VAL. log, logf, log10, and log10f return a value that
will compare equal to -HUGE for non-positive arguments and set
errno to EDOM. In addition, a message indicating DOMAIN error
is printed on the standard error output. pow and powf return
zero and set errno to EDOM when x is 0 and y is non-positive,
Copyright 1994 Novell, Inc. Page 2
exp(3M) exp(3M)
or when x is negative and y is non-integral. In addition, a
message indicating DOMAIN error is printed on the standard
error output. sqrt and sqrtf return zero and set errno to
EDOM when x is negative. In addition, a message indicating
DOMAIN error is printed on the standard error output. These
error handling procedures may be changed with the function
matherr.
REFERENCES
cc(1), hypot(3M), matherr(3M), sinh(3M)
Copyright 1994 Novell, Inc. Page 3