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