VxWorks Reference Manual : Libraries

ansiMath

NAME

ansiMath - ANSI math documentation

ROUTINES

asin( ) - compute an arc sine (ANSI)
acos( ) - compute an arc cosine (ANSI)
atan( ) - compute an arc tangent (ANSI)
atan2( ) - compute the arc tangent of y/x (ANSI)
ceil( ) - compute the smallest integer greater than or equal to a specified value (ANSI)
cosh( ) - compute a hyperbolic cosine (ANSI)
exp( ) - compute an exponential value (ANSI)
fabs( ) - compute an absolute value (ANSI)
floor( ) - compute the largest integer less than or equal to a specified value (ANSI)
fmod( ) - compute the remainder of x/y (ANSI)
frexp( ) - break a floating-point number into a normalized fraction and power of 2 (ANSI)
ldexp( ) - multiply a number by an integral power of 2 (ANSI)
log( ) - compute a natural logarithm (ANSI)
log10( ) - compute a base-10 logarithm (ANSI)
modf( ) - separate a floating-point number into integer and fraction parts (ANSI)
pow( ) - compute the value of a number raised to a specified power (ANSI)
sin( ) - compute a sine (ANSI)
cos( ) - compute a cosine (ANSI)
sinh( ) - compute a hyperbolic sine (ANSI)
sqrt( ) - compute a non-negative square root (ANSI)
tan( ) - compute a tangent (ANSI)
tanh( ) - compute a hyperbolic tangent (ANSI)

DESCRIPTION

The header math.h declares several mathematical functions and defines one macro. The functions take double arguments and return double values.

The macro defined is:

HUGE_VAL
expands to a positive double expression, not necessarily representable as a float.

The behavior of each of these functions is defined for all representable values of their input arguments. Each function executes as if it were a single operation, without generating any externally visible exceptions.

For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is defined. The description of each function lists any applicable domain errors. On a domain error, the function returns an implementation-defined value; the value EDOM is stored in errno.

Similarly, a range error occurs if the result of the function cannot be represented as a double value. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value HUGE_VAL, with the same sign (except for the tan( ) function) as the correct value of the function; the value ERANGE is stored in errno. If the result underflows (the type), the function returns zero; whether the integer expression errno acquires the value ERANGE is implementation defined.

INCLUDE FILES

math.h

SEE ALSO

mathALib, American National Standard X3.159-1989


Libraries : Routines

asin( )

NAME

asin( ) - compute an arc sine (ANSI)

SYNOPSIS

double asin
    (
    double x /* number between -1 and 1 */
    )

DESCRIPTION

This routine returns the principal value of the arc sine of x in double precision (IEEE double, 53 bits). If x is the sine of an angle T, this function returns T.

A domain error occurs for arguments not in the range [-1,+1].

INCLUDE FILES

math.h

RETURNS

The double-precision arc sine of x in the range [-pi/2,pi/2] radians.

Special cases:
    If x is NaN, asin( ) returns x.
    If |x|>1, it returns NaN.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

acos( )

NAME

acos( ) - compute an arc cosine (ANSI)

SYNOPSIS

double acos
    (
    double x /* number between -1 and 1 */
    )

DESCRIPTION

This routine returns principal value of the arc cosine of x in double precision (IEEE double, 53 bits). If x is the cosine of an angle T, this function returns T.

A domain error occurs for arguments not in the range [-1,+1].

INCLUDE FILES

math.h

RETURNS

The double-precision arc cosine of x in the range [0,pi] radians.

Special cases:
    If x is NaN, acos( ) returns x.
    If |x|>1, it returns NaN.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

atan( )

NAME

atan( ) - compute an arc tangent (ANSI)

SYNOPSIS

double atan
    (
    double x /* tangent of an angle */
    )

DESCRIPTION

This routine returns the principal value of the arc tangent of x in double precision (IEEE double, 53 bits). If x is the tangent of an angle T, this function returns T (in radians).

INCLUDE FILES

math.h

RETURNS

The double-precision arc tangent of x in the range [-pi/2,pi/2] radians. Special case: if x is NaN, atan( ) returns x itself.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

atan2( )

NAME

atan2( ) - compute the arc tangent of y/x (ANSI)

SYNOPSIS

double atan2
    (
    double y, /* numerator */
    double x  /* denominator */
    )

DESCRIPTION

This routine returns the principal value of the arc tangent of y/x in double precision (IEEE double, 53 bits). This routine uses the signs of both arguments to determine the quadrant of the return value. A domain error may occur if both arguments are zero.

INCLUDE FILES

math.h

RETURNS

The double-precision arc tangent of y/x, in the range [-pi,pi] radians.

Special cases:
    Notations: atan2(y,x) == ARG (x+iy) == ARG(x,y).

ARG(NAN, (anything)) is NaN
ARG((anything), NaN) is NaN
ARG(+(anything but NaN), +-0) is +-0
ARG(-(anything but NaN), +-0) is +-PI
ARG(0, +-(anything but 0 and NaN)) is +-PI/2
ARG(+INF, +-(anything but INF and NaN)) is +-0
ARG(-INF, +-(anything but INF and NaN)) is +-PI
ARG(+INF, +-INF) is +-PI/4
ARG(-INF, +-INF) is +-3PI/4
ARG((anything but 0, NaN, and INF),+-INF) is +-PI/2

SEE ALSO

ansiMath, mathALib


Libraries : Routines

ceil( )

NAME

ceil( ) - compute the smallest integer greater than or equal to a specified value (ANSI)

SYNOPSIS

double ceil
    (
    double v /* value to find the ceiling of */
    )

DESCRIPTION

This routine returns the smallest integer greater than or equal to v, in double precision.

INCLUDE FILES

math.h

RETURNS

The smallest integral value greater than or equal to v, in double precision.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

cosh( )

NAME

cosh( ) - compute a hyperbolic cosine (ANSI)

SYNOPSIS

double cosh
    (
    double x /* value to compute the hyperbolic cosine of */
    )

DESCRIPTION

This routine returns the hyperbolic cosine of x in double precision (IEEE double, 53 bits).

A range error occurs if x is too large.

INCLUDE FILES

math.h

RETURNS

The double-precision hyperbolic cosine of x.

Special cases:
    If x is +INF, -INF, or NaN, cosh( ) returns x.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

exp( )

NAME

exp( ) - compute an exponential value (ANSI)

SYNOPSIS

double exp
    (
    double x /* exponent */
    )

DESCRIPTION

This routine returns the exponential value of x in double precision (IEEE double, 53 bits).

A range error occurs if x is too large.

INCLUDE FILES

math.h

RETURNS

The double-precision exponential value of x.

Special cases:
    If x is +INF or NaN, exp( ) returns x.
    If x is -INF, it returns 0.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

fabs( )

NAME

fabs( ) - compute an absolute value (ANSI)

SYNOPSIS

double fabs
    (
    double v /* number to return the absolute value of */
    )

DESCRIPTION

This routine returns the absolute value of v in double precision.

INCLUDE FILES

math.h

RETURNS

The double-precision absolute value of v.

ERRNO

EDOM, ERANGE

SEE ALSO

ansiMath, mathALib


Libraries : Routines

floor( )

NAME

floor( ) - compute the largest integer less than or equal to a specified value (ANSI)

SYNOPSIS

double floor
    (
    double v /* value to find the floor of */
    )

DESCRIPTION

This routine returns the largest integer less than or equal to v, in double precision.

INCLUDE FILES

math.h

RETURNS

The largest integral value less than or equal to v, in double precision.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

fmod( )

NAME

fmod( ) - compute the remainder of x/y (ANSI)

SYNOPSIS

double fmod
    (
    double x, /* numerator */
    double y  /* denominator */
    )

DESCRIPTION

This routine returns the remainder of x/y with the sign of x, in double precision.

INCLUDE FILES

math.h

RETURNS

The value x - i * y, for some integer i. If y is non-zero, the result has the same sign as x and magnitude less than the magnitude of y. If y is zero, fmod( ) returns zero.

ERRNO

EDOM

SEE ALSO

ansiMath, mathALib


Libraries : Routines

frexp( )

NAME

frexp( ) - break a floating-point number into a normalized fraction and power of 2 (ANSI)

SYNOPSIS

double frexp
    (
    double value, /* number to be normalized */
    int *  pexp   /* pointer to the exponent */
    )

DESCRIPTION

This routine breaks a double-precision number value into a normalized fraction and integral power of 2. It stores the integer exponent in pexp.

INCLUDE FILES

math.h

RETURNS

The double-precision value x, such that the magnitude of x is in the interval [1/2,1) or zero, and value equals x times 2 to the power of pexp. If value is zero, both parts of the result are zero.

ERRNO

EDOM

SEE ALSO

ansiMath


Libraries : Routines

ldexp( )

NAME

ldexp( ) - multiply a number by an integral power of 2 (ANSI)

SYNOPSIS

double ldexp
    (
    double v,   /* a floating point number */
    int    xexp /* exponent */
    )

DESCRIPTION

This routine multiplies a floating-point number by an integral power of 2. A range error may occur.

INCLUDE FILES

math.h

RETURNS

The double-precision value of v times 2 to the power of xexp.

SEE ALSO

ansiMath


Libraries : Routines

log( )

NAME

log( ) - compute a natural logarithm (ANSI)

SYNOPSIS

double log
    (
    double x /* value to compute the natural logarithm of */
    )

DESCRIPTION

This routine returns the natural logarithm of x in double precision (IEEE double, 53 bits).

A domain error occurs if the argument is negative. A range error may occur if the argument is zero.

INCLUDE FILES

math.h

RETURNS

The double-precision natural logarithm of x.

Special cases:
    If x < 0 (including -INF), it returns NaN with signal.
    If x is +INF, it returns x with no signal.
    If x is 0, it returns -INF with signal.
    If x is NaN it returns x with no signal.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

log10( )

NAME

log10( ) - compute a base-10 logarithm (ANSI)

SYNOPSIS

double log10
    (
    double x /* value to compute the base-10 logarithm of */
    )

DESCRIPTION

This routine returns the base 10 logarithm of x in double precision (IEEE double, 53 bits).

A domain error occurs if the argument is negative. A range error may if the argument is zero.

INCLUDE FILES

math.h

RETURNS

The double-precision base-10 logarithm of x.

Special cases:
    If x < 0, log10( ) returns NaN with signal.
    if x is +INF, it returns x with no signal.
    if x is 0, it returns -INF with signal.
    if x is NaN it returns x with no signal.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

modf( )

NAME

modf( ) - separate a floating-point number into integer and fraction parts (ANSI)

SYNOPSIS

double modf
    (
    double   value,   /* value to split */
    double * pIntPart /* where integer portion is stored */
    )

DESCRIPTION

This routine stores the integer portion of value in pIntPart and returns the fractional portion. Both parts are double precision and will have the same sign as value.

INCLUDE FILES

math.h

RETURNS

The double-precision fractional portion of value.

SEE ALSO

ansiMath, frexp( ), ldexp( )


Libraries : Routines

pow( )

NAME

pow( ) - compute the value of a number raised to a specified power (ANSI)

SYNOPSIS

double pow
    (
    double x, /* operand */
    double y  /* exponent */
    )

DESCRIPTION

This routine returns x to the power of y in double precision (IEEE double, 53 bits).

A domain error occurs if x is negative and y is not an integral value. A domain error occurs if the result cannot be represented when x is zero and y is less than or equal to zero. A range error may occur.

INCLUDE FILES

math.h

RETURNS

The double-precision value of x to the power of y.

Special cases:
(anything) ** 0 is 1
(anything) ** 1 is itself
(anything) ** NaN is NaN
NaN ** (anything except 0) is NaN
+-(anything > 1) ** +INF is +INF
+-(anything > 1) ** -INF is +0
+-(anything < 1) ** +INF is +0
+-(anything < 1) ** -INF is +INF
+-1 ** +-INF is NaN, signal INVALID
+0 ** +(anything non-0, NaN) is +0
-0 ** +(anything non-0, NaN, odd int) is +0
+0 ** -(anything non-0, NaN) is +INF, signal DIV-BY-ZERO
-0 ** -(anything non-0, NaN, odd int) is +INF with signal
-0 ** (odd integer) = -(+0 ** (odd integer))
+INF ** +(anything except 0, NaN) is +INF
+INF ** -(anything except 0, NaN) is +0
-INF ** (odd integer) = -(+INF ** (odd integer))
-INF ** (even integer) = (+INF ** (even integer))
-INF ** -(any non-integer, NaN) is NaN with signal
-(x=anything) ** (k=integer) is (-1)**k * (x ** k)
-(anything except 0) ** (non-integer) is NaN with signal

SEE ALSO

ansiMath, mathALib


Libraries : Routines

sin( )

NAME

sin( ) - compute a sine (ANSI)

SYNOPSIS

double sin
    (
    double x /* angle in radians */
    )

DESCRIPTION

This routine computes the sine of x in double precision. The angle x is expressed in radians.

INCLUDE FILES

math.h

RETURNS

The double-precision sine of x.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

cos( )

NAME

cos( ) - compute a cosine (ANSI)

SYNOPSIS

double cos
    (
    double x /* angle in radians */
    )

DESCRIPTION

This routine computes the cosine of x in double precision. The angle x is expressed in radians.

INCLUDE FILES

math.h

RETURNS

The double-precision cosine of x.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

sinh( )

NAME

sinh( ) - compute a hyperbolic sine (ANSI)

SYNOPSIS

double sinh
    (
    double x /* number whose hyperbolic sine is required */
    )

DESCRIPTION

This routine returns the hyperbolic sine of x in double precision (IEEE double, 53 bits).

A range error occurs if x is too large.

INCLUDE FILES

math.h

RETURNS

The double-precision hyperbolic sine of x.

Special cases:
    If x is +INF, -INF, or NaN, sinh( ) returns x.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

sqrt( )

NAME

sqrt( ) - compute a non-negative square root (ANSI)

SYNOPSIS

double sqrt
    (
    double x /* value to compute the square root of */
    )

DESCRIPTION

This routine computes the non-negative square root of x in double precision. A domain error occurs if the argument is negative.

INCLUDE FILES

math.h

RETURNS

The double-precision square root of x or 0 if x is negative.

ERRNO

EDOM

SEE ALSO

ansiMath, mathALib


Libraries : Routines

tan( )

NAME

tan( ) - compute a tangent (ANSI)

SYNOPSIS

double tan
    (
    double x /* angle in radians */
    )

DESCRIPTION

This routine computes the tangent of x in double precision. The angle x is expressed in radians.

INCLUDE FILES

math.h

RETURNS

The double-precision tangent of x.

SEE ALSO

ansiMath, mathALib


Libraries : Routines

tanh( )

NAME

tanh( ) - compute a hyperbolic tangent (ANSI)

SYNOPSIS

double tanh
    (
    double x /* number whose hyperbolic tangent is required */
    )

DESCRIPTION

This routine returns the hyperbolic tangent of x in double precision (IEEE double, 53 bits).

INCLUDE FILES

math.h

RETURNS

The double-precision hyperbolic tangent of x.

Special cases:
    If x is NaN, tanh( ) returns NaN.

SEE ALSO

ansiMath, mathALib