wait.2: Add ESRCH for when pid == INT_MIN
[man-pages.git] / man3 / hypot.3
blobc595f11622f340502011ea011df7b320fce013d4
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
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)
32 .\"
33 .TH HYPOT 3 2021-03-22 ""  "Linux Programmer's Manual"
34 .SH NAME
35 hypot, hypotf, hypotl \- Euclidean distance function
36 .SH SYNOPSIS
37 .nf
38 .B #include <math.h>
39 .PP
40 .BI "double hypot(double " x ", double " y );
41 .BI "float hypotf(float " x ", float " y );
42 .BI "long double hypotl(long double " x ", long double " y );
43 .fi
44 .PP
45 Link with \fI\-lm\fP.
46 .PP
47 .RS -4
48 Feature Test Macro Requirements for glibc (see
49 .BR feature_test_macros (7)):
50 .RE
51 .PP
52 .BR hypot ():
53 .nf
54     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
55         || _XOPEN_SOURCE
56         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
57         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
58 .fi
59 .PP
60 .BR hypotf (),
61 .BR hypotl ():
62 .nf
63     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
64         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
65         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
66 .fi
67 .SH DESCRIPTION
68 These functions return
69 .RI sqrt( x * x + y * y ).
70 This is the length of the hypotenuse of a right-angled triangle
71 with sides of length
72 .I x
73 and
74 .IR y ,
75 or the distance of the point
76 .RI ( x , y )
77 from the origin.
78 .PP
79 The calculation is performed without undue overflow or underflow
80 during the intermediate steps of the calculation.
81 .\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
82 .\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
83 .SH RETURN VALUE
84 On success, these functions return the length of the hypotenuse of
85 a right-angled triangle
86 with sides of length
87 .I x
88 and
89 .IR y .
90 .PP
92 .I x
94 .I y
95 is an infinity,
96 positive infinity is returned.
97 .PP
99 .I x
101 .I y
102 is a NaN,
103 and the other argument is not an infinity,
104 a NaN is returned.
106 If the result overflows,
107 a range error occurs,
108 and the functions return
109 .BR HUGE_VAL ,
110 .BR HUGE_VALF ,
112 .BR HUGE_VALL ,
113 respectively.
115 If both arguments are subnormal, and the result is subnormal,
116 .\" Actually, could the result not be subnormal if both arguments
117 .\" are subnormal?  I think not -- mtk, Jul 2008
118 a range error occurs,
119 and the correct result is returned.
120 .SH ERRORS
122 .BR math_error (7)
123 for information on how to determine whether an error has occurred
124 when calling these functions.
126 The following errors can occur:
128 Range error: result overflow
129 .I errno
130 is set to
131 .BR ERANGE .
132 An overflow floating-point exception
133 .RB ( FE_OVERFLOW )
134 is raised.
136 Range error: result underflow
137 An underflow floating-point exception
138 .RB ( FE_UNDERFLOW )
139 is raised.
141 These functions do not set
142 .IR errno
143 for this case.
144 .\" This is intentional; see
145 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6795
146 .SH ATTRIBUTES
147 For an explanation of the terms used in this section, see
148 .BR attributes (7).
149 .ad l
152 allbox;
153 lbx lb lb
154 l l l.
155 Interface       Attribute       Value
157 .BR hypot (),
158 .BR hypotf (),
159 .BR hypotl ()
160 T}      Thread safety   MT-Safe
164 .sp 1
165 .SH CONFORMING TO
166 C99, POSIX.1-2001, POSIX.1-2008.
168 The variant returning
169 .I double
170 also conforms to
171 SVr4, 4.3BSD.
172 .SH SEE ALSO
173 .BR cabs (3),
174 .BR sqrt (3)