]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sqrt.3
010d30561928d5fe0e579ff79b154f1c5af03800
[thirdparty/man-pages.git] / man3 / sqrt.3
1 '\" t
2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <mtk.manpages@gmail.com>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .\" References consulted:
9 .\" Linux libc source code
10 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
11 .\" 386BSD man pages
12 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
13 .\" Modified 2002-07-27 by Walter Harms
14 .\" (walter.harms@informatik.uni-oldenburg.de)
15 .TH sqrt 3 (date) "Linux man-pages (unreleased)"
16 .SH NAME
17 sqrt, sqrtf, sqrtl \- square root function
18 .SH LIBRARY
19 Math library
20 .RI ( libm ", " \-lm )
21 .SH SYNOPSIS
22 .nf
23 .B #include <math.h>
24 .PP
25 .BI "double sqrt(double " x );
26 .BI "float sqrtf(float " x );
27 .BI "long double sqrtl(long double " x );
28 .fi
29 .PP
30 .RS -4
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
33 .RE
34 .PP
35 .BR sqrtf (),
36 .BR sqrtl ():
37 .nf
38 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
39 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
40 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
41 .fi
42 .SH DESCRIPTION
43 These functions return the nonnegative square root of
44 .IR x .
45 .SH RETURN VALUE
46 On success, these functions return the square root of
47 .IR x .
48 .PP
49 If
50 .I x
51 is a NaN, a NaN is returned.
52 .PP
53 If
54 .I x
55 is +0 (\-0), +0 (\-0) is returned.
56 .PP
57 If
58 .I x
59 is positive infinity, positive infinity is returned.
60 .PP
61 If
62 .I x
63 is less than \-0,
64 a domain error occurs,
65 and a NaN is returned.
66 .SH ERRORS
67 See
68 .BR math_error (7)
69 for information on how to determine whether an error has occurred
70 when calling these functions.
71 .PP
72 The following errors can occur:
73 .TP
74 Domain error: \fIx\fP less than \-0
75 .I errno
76 is set to
77 .BR EDOM .
78 An invalid floating-point exception
79 .RB ( FE_INVALID )
80 is raised.
81 .SH ATTRIBUTES
82 For an explanation of the terms used in this section, see
83 .BR attributes (7).
84 .ad l
85 .nh
86 .TS
87 allbox;
88 lbx lb lb
89 l l l.
90 Interface Attribute Value
91 T{
92 .BR sqrt (),
93 .BR sqrtf (),
94 .BR sqrtl ()
95 T} Thread safety MT-Safe
96 .TE
97 .hy
98 .ad
99 .sp 1
100 .SH STANDARDS
101 C11, POSIX.1-2008.
102 .SH HISTORY
103 C99, POSIX.1-2001.
104 .PP
105 The variant returning
106 .I double
107 also conforms to
108 SVr4, 4.3BSD, C89.
109 .SH SEE ALSO
110 .BR cbrt (3),
111 .BR csqrt (3),
112 .BR hypot (3)