2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The Berkeley software License Agreement specifies the terms and conditions
28 .\" for redistribution.
31 .\" Copyright (c) 1985 Regents of the University of California.
32 .\" All rights reserved.
33 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
34 .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved.
35 .\" Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
37 .TH SQRT 3M "Jul 12, 2006" "SunOS 5.11" "Mathematical Library Functions"
39 sqrt, sqrtf, sqrtl \- square root function
43 c99 [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ]
46 \fBdouble\fR \fBsqrt\fR(\fBdouble\fR \fIx\fR);
51 \fBfloat\fR \fBsqrtf\fR(\fBfloat\fR \fIx\fR);
56 \fBlong double\fR \fBsqrtl\fR(\fBlong double\fR \fIx\fR);
62 These functions compute the square root of their argument \fIx\fR.
66 Upon successful completion, these functions return the square root of \fIx\fR.
69 For finite values of \fIx\fR < \(mi0, a domain error occurs and either a NaN
70 (if supported) or an implementation-defined value is returned.
73 If \fIx\fR is NaN, a NaN is returned.
76 If \fIx\fR is \(+-0 or +Inf, \fIx\fR is returned.
79 If \fIx\fR is \(miInf, a domain error occurs and a NaN is returned.
83 These functions will fail if:
92 The finite value of \fIx\fR is < \(mi0 or \fIx\fR is \(miInf.
94 If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is
95 non-zero, the invalid floating-point exception is raised.
97 The \fBsqrt()\fR function sets \fBerrno\fR to \fBEDOM\fR if the value of
104 An application wanting to check for exceptions should call
105 \fBfeclearexcept\fR(\fBFE_ALL_EXCEPT\fR) before calling these functions. On
106 return, if \fBfetestexcept\fR(\fBFE_INVALID\fR | \fBFE_DIVBYZERO\fR |
107 \fBFE_OVERFLOW\fR | \fBFE_UNDERFLOW\fR) is non-zero, an exception has been
108 raised. An application should either examine the return value or check the
109 floating point exception flags to detect exceptions.
112 An application can also set \fBerrno\fR to 0 before calling \fBsqrt()\fR. On
113 return, if \fBerrno\fR is non-zero, an error has occurred. The \fBsqrtf()\fR
114 and \fBsqrtl()\fR functions do not set \fBerrno\fR.
118 See \fBattributes\fR(5) for descriptions of the following attributes:
127 ATTRIBUTE TYPE ATTRIBUTE VALUE
129 Interface Stability Standard
137 \fBfeclearexcept\fR(3M), \fBfetestexcept\fR(3M), \fBisnan\fR(3M),
138 \fBmath.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5)