Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ exp(3M) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

matherr(3M)

hc(1)

exp(3M)

NAME

exp, log, log10, pow, powr, sqrt, cbrt, expf, logf, log10f, powf, sqrtf − exponential, logarithm, power, square root, cube root functions

SYNOPSIS

#include <math.h>

double exp (x)
double x;

double log (x)
double x;

double log10 (x)
double x;

double pow (x, y)
double x, y;

double powr (x, y)
double x, y;

double sqrt (x)
double x;

double cbrt (x)
double x;

float expf (float x)

float logf (float x)

float log10f (float x)

float powf (float x, float y)

float sqrtf (float x)

DESCRIPTION

exp and expf return e to the power of x. 

Log and logf return the natural logarithm of x. The value of x must be positive. 

Log10 and log10f return the logarithm base ten of x. The value of x must be positive. 

Pow, powr, and powf return x to the power of y.  If x is zero, y must be positive.  If x is negative, y must be an integer. 

Pow uses double precision arithmetic, powr uses single precision arithmetic, and powf uses a combination of single and double precision arithmetic.  A loss in single precision accuracy may be experienced with the powr function, but the powf function minimizes such loss. 

Sqrt and sqrtf return the zero or positive square root of x. The value of x must be zero or positive. 

Cbrt returns the cube root of x.

DIAGNOSTICS

All systems accept IEEE floating point reserved values. The use of these values may cause exception conditions. For the double precision functions:

EXP: result errno
overflow +HUGE ERANGE no message
underflow 0.0 ERANGE no message
x = +infinity +HUGE ERANGE no message
x = -infinity 0.0 ERANGE no message
x = NaN qNaN EDOM no message

LOG,LOG10: result errno
x < 0.0 -HUGE EDOM DOMAIN error message
x = 0.0 -HUGE EDOM SING error message
x = +infinity +infinity not set no message
x = -infinity qNaN EDOM no message
x = NaN qNaN EDOM no message

POW,POWR: result errno
overflow +HUGE ERANGE no message
underflow -HUGE ERANGE no message
x = 0.0, y <= 0.0 0.0 EDOM DOMAIN error message
x < 0.0, y not int 0.0 EDOM DOMAIN error message
x = NaN or y = NaN qNaN EDOM no message

SQRT: result errno
x < 0.0 0.0 EDOM DOMAIN error message
x = +infinity +infinity not set no message
x = -infinity 0.0 EDOM no message
x = NaN qNaN EDOM no message

CBRT: result errno
x = infinity infinity not set no message
x = NaN qNaN EDOM no message

In programs linked in one of the ANSI C compilation modes, messages will not be produced under any circumstances. 

In programs linked in one of the ANSI C compilation modes, and in programs linked in the 88open OCS-compliant mode, exp, log, log10, and pow return HUGE_VAL instead of HUGE. 

These error-handling procedures may be changed with the matherr(3M) function, if the program is not linked in ANSI C conforming mode (−Xc option).  See hc(1) for more information about compilation modes. 

For the single precision functions:

EXPF: result errno
overflow +infinity OVERFLOW no message
underflow 0.0 UNDERFLOW no message
x = +infinity +infinity not set no message
x = -infinity 0.0 not set no message
x = NaN qNaN DOMAIN no message

LOGF,LOG10F: result errno
x < 0.0 qNaN DOMAIN no message
x = 0.0 -infinity not set no message
x = +infinity +infinity not set no message
x = -infinity qNaN DOMAIN no message
x = NaN qNaN DOMAIN no message

POWF: result errno
overflow qNaN OVERFLOW no message
underflow qNaN UNDERFLOW no message
x = 0.0, y <= 0.0 qNaN DOMAIN no message
x < 0.0, y not int qNaN DOMAIN no message
x = NaN or y = NaN qNaN DOMAIN no message

SQRTF: result errno
x < 0.0 qNaN DOMAIN no message
x = +infinity +infinity not set no message
x = -infinity qNaN DOMAIN no message
x = NaN qNaN DOMAIN no message

In programs linked in one of the ANSI C compilation modes, expf, logf, log10f, powf, and sqrtf set errno to EDOM instead of DOMAIN, ERANGE instead of UNDERFLOW, and ERANGE instead of OVERFLOW. 

The matherr(3M) function has no effect on the single precision functions. 

PERFORMANCE IMPROVEMENTS

These functions check the integrity of their arguments for mathematical validity and conformance to the IEEE Floating-Point Arithmetic standard’s definition of numbers.  They also maintain high accuracy of computations through occasional use of higher precision arithmetic and lengthier computations designed to minimize round-off errors.  The library libm.a contains these robust functions. 
An alternate math library is provided, libM.a, which offers increased performance at the expense of argument checking and accuracy.  The checks for mathematical validity and IEEE numbers are not performed on these functions in this additional library.  Checks at the boundary conditions of minimum and maximum representable values, however, are conducted.  The accuracy losses are usually never more than 1-bit differences when compared with the robust versions.  This alternate library is intended for use when the characteristics of the arguments are well-understood and higher performance is preferred over increased accuracy.  One consequence of these less-robust functions is that erroneous arguments are not caught and may produce meaningless answers. 

SEE ALSO

matherr(3M), hc(1). 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026