VxWorks Reference Manual : Libraries
ansiMath - ANSI math documentation
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)
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.
math.h
mathALib, American National Standard X3.159-1989
asin( ) - compute an arc sine (ANSI)
double asin ( double x /* number between -1 and 1 */ )
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].
math.h
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.
acos( ) - compute an arc cosine (ANSI)
double acos ( double x /* number between -1 and 1 */ )
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].
math.h
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.
atan( ) - compute an arc tangent (ANSI)
double atan ( double x /* tangent of an angle */ )
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).
math.h
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.
atan2( ) - compute the arc tangent of y/x (ANSI)
double atan2 ( double y, /* numerator */ double x /* denominator */ )
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.
math.h
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
ceil( ) - compute the smallest integer greater than or equal to a specified value (ANSI)
double ceil ( double v /* value to find the ceiling of */ )
This routine returns the smallest integer greater than or equal to v, in double precision.
math.h
The smallest integral value greater than or equal to v, in double precision.
cosh( ) - compute a hyperbolic cosine (ANSI)
double cosh ( double x /* value to compute the hyperbolic cosine of */ )
This routine returns the hyperbolic cosine of x in double precision (IEEE double, 53 bits).
A range error occurs if x is too large.
math.h
The double-precision hyperbolic cosine of x.
Special cases:
If x is +INF, -INF, or NaN, cosh( ) returns x.
exp( ) - compute an exponential value (ANSI)
double exp ( double x /* exponent */ )
This routine returns the exponential value of x in double precision (IEEE double, 53 bits).
A range error occurs if x is too large.
math.h
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.
fabs( ) - compute an absolute value (ANSI)
double fabs ( double v /* number to return the absolute value of */ )
This routine returns the absolute value of v in double precision.
math.h
The double-precision absolute value of v.
EDOM, ERANGE
floor( ) - compute the largest integer less than or equal to a specified value (ANSI)
double floor ( double v /* value to find the floor of */ )
This routine returns the largest integer less than or equal to v, in double precision.
math.h
The largest integral value less than or equal to v, in double precision.
fmod( ) - compute the remainder of x/y (ANSI)
double fmod ( double x, /* numerator */ double y /* denominator */ )
This routine returns the remainder of x/y with the sign of x, in double precision.
math.h
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.
EDOM
frexp( ) - break a floating-point number into a normalized fraction and power of 2 (ANSI)
double frexp ( double value, /* number to be normalized */ int * pexp /* pointer to the exponent */ )
This routine breaks a double-precision number value into a normalized fraction and integral power of 2. It stores the integer exponent in pexp.
math.h
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.
EDOM
ldexp( ) - multiply a number by an integral power of 2 (ANSI)
double ldexp ( double v, /* a floating point number */ int xexp /* exponent */ )
This routine multiplies a floating-point number by an integral power of 2. A range error may occur.
math.h
The double-precision value of v times 2 to the power of xexp.
log( ) - compute a natural logarithm (ANSI)
double log ( double x /* value to compute the natural logarithm of */ )
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.
math.h
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.
log10( ) - compute a base-10 logarithm (ANSI)
double log10 ( double x /* value to compute the base-10 logarithm of */ )
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.
math.h
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.
modf( ) - separate a floating-point number into integer and fraction parts (ANSI)
double modf ( double value, /* value to split */ double * pIntPart /* where integer portion is stored */ )
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.
math.h
The double-precision fractional portion of value.
pow( ) - compute the value of a number raised to a specified power (ANSI)
double pow ( double x, /* operand */ double y /* exponent */ )
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.
math.h
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
sin( ) - compute a sine (ANSI)
double sin ( double x /* angle in radians */ )
This routine computes the sine of x in double precision. The angle x is expressed in radians.
math.h
The double-precision sine of x.
cos( ) - compute a cosine (ANSI)
double cos ( double x /* angle in radians */ )
This routine computes the cosine of x in double precision. The angle x is expressed in radians.
math.h
The double-precision cosine of x.
sinh( ) - compute a hyperbolic sine (ANSI)
double sinh ( double x /* number whose hyperbolic sine is required */ )
This routine returns the hyperbolic sine of x in double precision (IEEE double, 53 bits).
A range error occurs if x is too large.
math.h
The double-precision hyperbolic sine of x.
Special cases:
If x is +INF, -INF, or NaN, sinh( ) returns x.
sqrt( ) - compute a non-negative square root (ANSI)
double sqrt ( double x /* value to compute the square root of */ )
This routine computes the non-negative square root of x in double precision. A domain error occurs if the argument is negative.
math.h
The double-precision square root of x or 0 if x is negative.
EDOM
tan( ) - compute a tangent (ANSI)
double tan ( double x /* angle in radians */ )
This routine computes the tangent of x in double precision. The angle x is expressed in radians.
math.h
The double-precision tangent of x.
tanh( ) - compute a hyperbolic tangent (ANSI)
double tanh ( double x /* number whose hyperbolic tangent is required */ )
This routine returns the hyperbolic tangent of x in double precision (IEEE double, 53 bits).
math.h
The double-precision hyperbolic tangent of x.
Special cases:
If x is NaN, tanh( ) returns NaN.