SQRT(3M)SQRT(3M)NAME
sqrt, fsqrt, sqrtf, sqrtl, cbrt, cbrtl - cube root, square root
SYNOPSIS
#include <math.h>
double sqrt(double x);
float fsqrt(float x);
float sqrtf(float x);
long double sqrtl(long double x);
double cbrt(double x);
long double cbrtl(long double x);
DESCRIPTION
The single-precision and long double-precision routines listed above are
only available in the standard math library, -lm, and in -lmx.
The sqrt functions return the nonnegative square root of their single
argument x. The function sqrt both accepts and returns values of type
double. The functions fsqrt and sqrtf accept and return float values.
The function sqrtl both accepts and returns values of type long double.
A fast version of sqrt and fsqrt which are slightly less accurate are
available in the library -lfastm. On mips2 and newer processors, those
routines are identical to the ones in libm.a, because there are hardware
square root instructions.
The cbrt functions return the cube root of their single argument x. The
function cbrt both accepts and returns values of type double. The
function cbrtl both accepts and returns values of type long double.
DIAGNOSTICS
In the diagnostics below, functions in the standard math library libm.a,
are referred to as -lm versions, those in math library libmx.a are
referred to as -lmx versions, and those in the the BSD math library
libm43.a are referred to as -lm43 versions. The -lm and -lmx versions
always return the default Quiet NaN and set errno to EDOM when a NaN is
used as an argument. A NaN argument usually causes the -lm43 versions to
return the same argument. The -lm43 versions never set errno.
If x is negative, the sqrt functions return a quiet NaN. The -lm and
-lm43 versions also set the flag in the floating-point coprocessor to
indicate an invalid operation. The functions in the standard math library
-lm and in library -lmx also set errno to EDOM.
See matherr(3M) for a description of error handling for -lmx functions.
NOTES
Long double operations on this system are only supported in round to
nearest rounding mode (the default). The system must be in round to
nearest rounding mode when calling any of the long double functions, or
Page 1
SQRT(3M)SQRT(3M)
incorrect answers will result.
Users concerned with portability to other computer systems should note
that the long double and float versions of these functions are optional
according to the ANSI C Programming Language Specification ISO/IEC 9899 :
1990 (E).
Long double functions have been renamed to be compliant with the ANSI-C
standard, however to be backward compatible, they may still be called
with the double precision function name prefixed with a q.
User's code which calls sqrt() or sqrtf() will be compiled into the
machine instruction sqrt.d or sqrt.s if the code #includes <math.h>.
ERROR (due to Roundoff etc.)cbrt is accurate to within 0.7 ulps.
libm.a sqrt conforms to IEEE 754 and is correctly rounded in accordance
with the rounding mode in force; the error is less than half an ulp in
the default mode (round to nearest).
The libfastm.a sqrt and fsqrt error is a maximum of one ulp. (See
however, the comments regarding -lfastm above.)
An ulp is one Unit in the Last Place carried.
SEE ALSOmath(3M), libmx(3M)AUTHOR
W. Kahan
Page 2