]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/hypot.3
bpf-helpers.7: Refresh against Linux 5.0-rc8
[thirdparty/man-pages.git] / man3 / hypot.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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.\"
4b8c67d9 33.TH HYPOT 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
34.SH NAME
35hypot, hypotf, hypotl \- Euclidean distance function
36.SH SYNOPSIS
37.nf
38.B #include <math.h>
68e4db0a 39.PP
fea681da 40.BI "double hypot(double " x ", double " y );
fea681da 41.BI "float hypotf(float " x ", float " y );
b9f02710 42.BI "long double hypotl(long double " x ", long double " y );
fea681da 43.fi
68e4db0a 44.PP
20c58d70 45Link with \fI\-lm\fP.
68e4db0a 46.PP
cc4615cc
MK
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
68e4db0a 51.PP
cc4615cc 52.ad l
6bc15b8b 53.BR hypot ():
49a3a478 54.RS 4
636ed4d5
MK
55_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
56 || _XOPEN_SOURCE
57 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
58 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
49a3a478 59.RE
6bc15b8b 60.br
cc4615cc
MK
61.BR hypotf (),
62.BR hypotl ():
49a3a478 63.RS 4
636ed4d5
MK
64_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
65 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
66 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
49a3a478 67.RE
cc4615cc 68.ad b
fea681da 69.SH DESCRIPTION
5600f73a 70These functions return
fea681da 71.RI sqrt( x * x + y * y ).
6bc15b8b 72This is the length of the hypotenuse of a right-angled triangle
fea681da
MK
73with sides of length
74.I x
75and
76.IR y ,
77or the distance of the point
78.RI ( x , y )
79from the origin.
847e0d88 80.PP
6bc15b8b
MK
81The calculation is performed without undue overflow or underflow
82during the intermediate steps of the calculation.
83.\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
84.\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
85.SH RETURN VALUE
86On success, these functions return the length of a right-angled triangle
87with sides of length
88.I x
e49f411f 89and
6bc15b8b 90.IR y .
847e0d88 91.PP
6bc15b8b
MK
92If
93.I x
94or
95.I y
96is an infinity,
97positive infinity is returned.
847e0d88 98.PP
6bc15b8b
MK
99If
100.I x
101or
102.I y
103is a NaN,
104and the other argument is not an infinity,
105a NaN is returned.
847e0d88 106.PP
6bc15b8b 107If the result overflows,
efe294cb 108a range error occurs,
6bc15b8b
MK
109and the functions return
110.BR HUGE_VAL ,
111.BR HUGE_VALF ,
112or
113.BR HUGE_VALL ,
114respectively.
847e0d88 115.PP
6bc15b8b
MK
116If both arguments are subnormal, and the result is subnormal,
117.\" Actually, could the result not be subnormal if both arguments
118.\" are subnormal? I think not -- mtk, Jul 2008
efe294cb 119a range error occurs,
6bc15b8b
MK
120and the correct result is returned.
121.SH ERRORS
122See
123.BR math_error (7)
124for information on how to determine whether an error has occurred
125when calling these functions.
126.PP
127The following errors can occur:
128.TP
129Range error: result overflow
130.I errno
131is set to
132.BR ERANGE .
133An overflow floating-point exception
134.RB ( FE_OVERFLOW )
135is raised.
136.TP
137Range error: result underflow
138.\" .I errno
139.\" is set to
140.\" .BR ERANGE .
141An underflow floating-point exception
142.RB ( FE_UNDERFLOW )
143is raised.
144.IP
145These functions do not set
146.IR errno
147for this case.
148.\" FIXME . Is it intentional that these functions do not set errno?
149.\" They do set errno for the overflow case.
150.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795
6d027764
MS
151.SH ATTRIBUTES
152For an explanation of the terms used in this section, see
153.BR attributes (7).
154.TS
155allbox;
156lbw27 lb lb
157l l l.
158Interface Attribute Value
159T{
160.BR hypot (),
161.BR hypotf (),
162.BR hypotl ()
163T} Thread safety MT-Safe
164.TE
847e0d88 165.sp 1
47297adb 166.SH CONFORMING TO
9a74e018 167C99, POSIX.1-2001, POSIX.1-2008.
847e0d88 168.PP
6bc15b8b
MK
169The variant returning
170.I double
171also conforms to
172SVr4, 4.3BSD.
47297adb 173.SH SEE ALSO
fea681da
MK
174.BR cabs (3),
175.BR sqrt (3)