|HP-UX Reference > C
HP-UX 11i Version 3: February 2007
cos(), cosf(), cosl(), cosw(), cosq() — cosine functions
cos() returns the cosine of x (x specified in radians).
On PA-RISC systems, cos() may lose accuracy when x is far from zero.
cosf() is a float version of cos(); it takes a float argument and returns a float result.
To use these functions compile either with the default -Ae option or with the -Aa and the -D_HPUX_SOURCE options.
To use (for Integrity servers) cosw() or cosq(), compile also with the -fpwidetypes option.
To use any of these functions, make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.
For more information, see the HP-UX floating-point guide for HP Integrity servers at the following site: http://www.hp.com/go/fp.
Millicode versions of the cos() and cosf() functions are available. Millicode versions of math library functions are usually faster than their counterparts in the standard library. To use these versions, compile your program with the +Olibcalls or the +Oaggressive optimization option.
For special cases, the millicode versions return the same values as their standard library counterparts (see the RETURN VALUE section).
cos(±0) returns 1.
If x is ±INFINITY, cos() returns NaN and raises the invalid exception.
If x is NaN, cos() returns NaN.
When it raises no other exception, whether cos() raises the inexact exception is unspecified.