]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/hypot.3
CPU_SET.3, INFINITY.3, __ppc_get_timebase.3, __ppc_set_ppr_med.3, __ppc_yield.3,...
[thirdparty/man-pages.git] / man3 / hypot.3
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 2016-03-15 "" "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 .br
42 .BI "float hypotf(float " x ", float " y );
43 .br
44 .BI "long double hypotl(long double " x ", long double " y );
45 .fi
46 .PP
47 Link with \fI\-lm\fP.
48 .PP
49 .in -4n
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
52 .in
53 .PP
54 .ad l
55 .BR hypot ():
56 .RS 4
57 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
58 || _XOPEN_SOURCE
59 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
60 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
61 .RE
62 .br
63 .BR hypotf (),
64 .BR hypotl ():
65 .RS 4
66 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
67 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
68 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
69 .RE
70 .ad b
71 .SH DESCRIPTION
72 These functions return
73 .RI sqrt( x * x + y * y ).
74 This is the length of the hypotenuse of a right-angled triangle
75 with sides of length
76 .I x
77 and
78 .IR y ,
79 or the distance of the point
80 .RI ( x , y )
81 from the origin.
82 .PP
83 The calculation is performed without undue overflow or underflow
84 during the intermediate steps of the calculation.
85 .\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
86 .\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
87 .SH RETURN VALUE
88 On success, these functions return the length of a right-angled triangle
89 with sides of length
90 .I x
91 and
92 .IR y .
93 .PP
94 If
95 .I x
96 or
97 .I y
98 is an infinity,
99 positive infinity is returned.
100 .PP
101 If
102 .I x
103 or
104 .I y
105 is a NaN,
106 and the other argument is not an infinity,
107 a NaN is returned.
108 .PP
109 If the result overflows,
110 a range error occurs,
111 and the functions return
112 .BR HUGE_VAL ,
113 .BR HUGE_VALF ,
114 or
115 .BR HUGE_VALL ,
116 respectively.
117 .PP
118 If both arguments are subnormal, and the result is subnormal,
119 .\" Actually, could the result not be subnormal if both arguments
120 .\" are subnormal? I think not -- mtk, Jul 2008
121 a range error occurs,
122 and the correct result is returned.
123 .SH ERRORS
124 See
125 .BR math_error (7)
126 for information on how to determine whether an error has occurred
127 when calling these functions.
128 .PP
129 The following errors can occur:
130 .TP
131 Range error: result overflow
132 .I errno
133 is set to
134 .BR ERANGE .
135 An overflow floating-point exception
136 .RB ( FE_OVERFLOW )
137 is raised.
138 .TP
139 Range error: result underflow
140 .\" .I errno
141 .\" is set to
142 .\" .BR ERANGE .
143 An underflow floating-point exception
144 .RB ( FE_UNDERFLOW )
145 is raised.
146 .IP
147 These functions do not set
148 .IR errno
149 for this case.
150 .\" FIXME . Is it intentional that these functions do not set errno?
151 .\" They do set errno for the overflow case.
152 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795
153 .SH ATTRIBUTES
154 For an explanation of the terms used in this section, see
155 .BR attributes (7).
156 .TS
157 allbox;
158 lbw27 lb lb
159 l l l.
160 Interface Attribute Value
161 T{
162 .BR hypot (),
163 .BR hypotf (),
164 .BR hypotl ()
165 T} Thread safety MT-Safe
166 .TE
167 .sp 1
168 .SH CONFORMING TO
169 C99, POSIX.1-2001, POSIX.1-2008.
170 .PP
171 The variant returning
172 .I double
173 also conforms to
174 SVr4, 4.3BSD.
175 .SH SEE ALSO
176 .BR cabs (3),
177 .BR sqrt (3)