]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
631c6898 MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
fea681da MK |
4 | .\" |
5 | .\" Permission is granted to make and distribute verbatim copies of this | |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
24 | .\" | |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
30 | .\" Modified 2002-07-27 by Walter Harms | |
31 | .\" (walter.harms@informatik.uni-oldenburg.de) | |
a1949252 | 32 | .TH SQRT 3 2008-08-05 "" "Linux Programmer's Manual" |
fea681da MK |
33 | .SH NAME |
34 | sqrt, sqrtf, sqrtl \- square root function | |
35 | .SH SYNOPSIS | |
36 | .nf | |
37 | .B #include <math.h> | |
38 | .sp | |
39 | .BI "double sqrt(double " x ); | |
d39541ec | 40 | .br |
fea681da | 41 | .BI "float sqrtf(float " x ); |
d39541ec | 42 | .br |
fea681da MK |
43 | .BI "long double sqrtl(long double " x ); |
44 | .fi | |
45 | .sp | |
20c58d70 | 46 | Link with \fI\-lm\fP. |
631c6898 MK |
47 | .sp |
48 | .in -4n | |
49 | Feature Test Macro Requirements for glibc (see | |
50 | .BR feature_test_macros (7)): | |
51 | .in | |
52 | .sp | |
53 | .ad l | |
54 | .BR sqrtf (), | |
55 | .BR sqrtl (): | |
b90c43a8 | 56 | .RS 4 |
8b0d34e4 MK |
57 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || |
58 | _POSIX_C_SOURCE\ >=\ 200112L; | |
b90c43a8 MK |
59 | .br |
60 | or | |
631c6898 | 61 | .I cc\ -std=c99 |
b90c43a8 MK |
62 | .RE |
63 | .ad | |
fea681da | 64 | .SH DESCRIPTION |
60a90ecd MK |
65 | The |
66 | .BR sqrt () | |
2fda57bd | 67 | function returns the nonnegative square root of \fIx\fP. |
631c6898 MK |
68 | .SH "RETURN VALUE" |
69 | On success, these functions return the square root of | |
70 | .IR x . | |
71 | ||
72 | If | |
73 | .I x | |
74 | is a NaN, a NaN is returned. | |
75 | ||
76 | If | |
77 | .I x | |
78 | is +0 (\-0), +0 (\-0) is returned. | |
79 | ||
80 | If | |
81 | .I x | |
82 | is positive infinity, positive infinity is returned. | |
83 | ||
84 | If | |
85 | .I x | |
86 | is less than \-0, | |
efe294cb | 87 | a domain error occurs, |
631c6898 | 88 | and a NaN is returned. |
fea681da | 89 | .SH ERRORS |
631c6898 MK |
90 | See |
91 | .BR math_error (7) | |
92 | for information on how to determine whether an error has occurred | |
93 | when calling these functions. | |
94 | .PP | |
95 | The following errors can occur: | |
fea681da | 96 | .TP |
631c6898 MK |
97 | Domain error: \fIx\fP less than \-0 |
98 | .I errno | |
99 | is set to | |
100 | .BR EDOM . | |
101 | An invalid floating-point exception | |
102 | .RB ( FE_INVALID ) | |
103 | is raised. | |
fea681da | 104 | .SH "CONFORMING TO" |
631c6898 MK |
105 | C99, POSIX.1-2001. |
106 | The variant returning | |
107 | .I double | |
108 | also conforms to | |
68e1685c | 109 | SVr4, 4.3BSD, C89. |
fea681da | 110 | .SH "SEE ALSO" |
36268806 MK |
111 | .BR cbrt (3), |
112 | .BR csqrt (3), | |
fea681da | 113 | .BR hypot (3) |