Debian Codegraph @

upstream/debian-unstable/man3/sqrt.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sqrt 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 sqrt, sqrtf, sqrtl \- square root function
10 .SH LIBRARY
11 Math library
12 .RI ( libm ,\~ \-lm )
13 .SH SYNOPSIS
14 .nf
15 .B #include <math.h>
16 .P
17 .BI "double sqrt(double " x );
18 .BI "float sqrtf(float " x );
19 .BI "long double sqrtl(long double " x );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR sqrtf (),
28 .BR sqrtl ():
29 .nf
30 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
31 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
32 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
33 .fi
34 .SH DESCRIPTION
35 These functions return the nonnegative square root of
36 .IR x .
37 .SH RETURN VALUE
38 On success, these functions return the square root of
39 .IR x .
40 .P
41 If
42 .I x
43 is a NaN, a NaN is returned.
44 .P
45 If
46 .I x
47 is +0 (\-0), +0 (\-0) is returned.
48 .P
49 If
50 .I x
51 is positive infinity, positive infinity is returned.
52 .P
53 If
54 .I x
55 is less than \-0,
56 a domain error occurs,
57 and a NaN is returned.
58 .SH ERRORS
59 See
60 .BR math_error (7)
61 for information on how to determine whether an error has occurred
62 when calling these functions.
63 .P
64 The following errors can occur:
65 .TP
66 Domain error: \f[I]x\f[] less than \-0
67 .I errno
68 is set to
69 .BR EDOM .
70 An invalid floating-point exception
71 .RB ( FE_INVALID )
72 is raised.
73 .SH ATTRIBUTES
74 For an explanation of the terms used in this section, see
75 .BR attributes (7).
76 .TS
77 allbox;
78 lbx lb lb
79 l l l.
80 Interface Attribute Value
81 T{
82 .na
83 .nh
84 .BR sqrt (),
85 .BR sqrtf (),
86 .BR sqrtl ()
87 T} Thread safety MT-Safe
88 .TE
89 .SH STANDARDS
90 C11, POSIX.1-2008.
91 .SH HISTORY
92 C99, POSIX.1-2001.
93 .P
94 The variant returning
95 .I double
96 also conforms to
97 SVr4, 4.3BSD, C89.
98 .SH SEE ALSO
99 .BR cbrt (3),
100 .BR csqrt (3),
101 .BR hypot (3)