Debian Codegraph @

upstream/debian-unstable/man3/hypot.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 hypot 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 hypot, hypotf, hypotl \- Euclidean distance 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 hypot(double " x ", double " y );
18 .BI "float hypotf(float " x ", float " y );
19 .BI "long double hypotl(long double " x ", long double " y );
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 hypot ():
28 .nf
29 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
30 || _XOPEN_SOURCE
31 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
32 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
33 .fi
34 .P
35 .BR hypotf (),
36 .BR hypotl ():
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
44 .RI sqrt( x * x + y * y ).
45 This is the length of the hypotenuse of a right-angled triangle
46 with sides of length
47 .I x
48 and
49 .IR y ,
50 or the distance of the point
51 .RI ( x , y )
52 from the origin.
53 .P
54 The calculation is performed without undue overflow or underflow
55 during the intermediate steps of the calculation.
56 .\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
57 .\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
58 .SH RETURN VALUE
59 On success, these functions return the length of the hypotenuse of
60 a right-angled triangle
61 with sides of length
62 .I x
63 and
64 .IR y .
65 .P
66 If
67 .I x
68 or
69 .I y
70 is an infinity,
71 positive infinity is returned.
72 .P
73 If
74 .I x
75 or
76 .I y
77 is a NaN,
78 and the other argument is not an infinity,
79 a NaN is returned.
80 .P
81 If the result overflows,
82 a range error occurs,
83 and the functions return
84 .BR HUGE_VAL ,
85 .BR HUGE_VALF ,
86 or
87 .BR HUGE_VALL ,
88 respectively.
89 .P
90 If both arguments are subnormal, and the result is subnormal,
91 .\" Actually, could the result not be subnormal if both arguments
92 .\" are subnormal? I think not -- mtk, Jul 2008
93 a range error occurs,
94 and the correct result is returned.
95 .SH ERRORS
96 See
97 .BR math_error (7)
98 for information on how to determine whether an error has occurred
99 when calling these functions.
100 .P
101 The following errors can occur:
102 .TP
103 Range error: result overflow
104 .I errno
105 is set to
106 .BR ERANGE .
107 An overflow floating-point exception
108 .RB ( FE_OVERFLOW )
109 is raised.
110 .TP
111 Range error: result underflow
112 An underflow floating-point exception
113 .RB ( FE_UNDERFLOW )
114 is raised.
115 .IP
116 These functions do not set
117 .I errno
118 for this case.
119 .\" This is intentional; see
120 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6795
121 .SH ATTRIBUTES
122 For an explanation of the terms used in this section, see
123 .BR attributes (7).
124 .TS
125 allbox;
126 lbx lb lb
127 l l l.
128 Interface Attribute Value
129 T{
130 .na
131 .nh
132 .BR hypot (),
133 .BR hypotf (),
134 .BR hypotl ()
135 T} Thread safety MT-Safe
136 .TE
137 .SH STANDARDS
138 C11, POSIX.1-2008.
139 .SH HISTORY
140 C99, POSIX.1-2001.
141 .P
142 The variant returning
143 .I double
144 also conforms to
145 SVr4, 4.3BSD.
146 .SH SEE ALSO
147 .BR cabs (3),
148 .BR sqrt (3)