]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/hypot.3
log2.3: Fixed feature test macro requirements
[thirdparty/man-pages.git] / man3 / hypot.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
28.\" Modified 2002-07-27 by Walter Harms
29.\" (walter.harms@informatik.uni-oldenburg.de)
30.\"
a1949252 31.TH HYPOT 3 2008-08-05 "" "Linux Programmer's Manual"
fea681da
MK
32.SH NAME
33hypot, hypotf, hypotl \- Euclidean distance function
34.SH SYNOPSIS
35.nf
36.B #include <math.h>
37.sp
38.BI "double hypot(double " x ", double " y );
d39541ec 39.br
fea681da 40.BI "float hypotf(float " x ", float " y );
d39541ec 41.br
b9f02710 42.BI "long double hypotl(long double " x ", long double " y );
fea681da
MK
43.fi
44.sp
20c58d70 45Link with \fI\-lm\fP.
cc4615cc
MK
46.sp
47.in -4n
48Feature Test Macro Requirements for glibc (see
49.BR feature_test_macros (7)):
50.in
51.sp
52.ad l
6bc15b8b
MK
53.BR hypot ():
54_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE; or
55.I cc\ -std=c99
56.br
cc4615cc
MK
57.BR hypotf (),
58.BR hypotl ():
6bc15b8b 59_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
cc4615cc
MK
60.I cc\ -std=c99
61.ad b
fea681da
MK
62.SH DESCRIPTION
63The
63aa9df0 64.BR hypot ()
fea681da
MK
65function returns
66.RI sqrt( x * x + y * y ).
6bc15b8b 67This is the length of the hypotenuse of a right-angled triangle
fea681da
MK
68with sides of length
69.I x
70and
71.IR y ,
72or the distance of the point
73.RI ( x , y )
74from the origin.
6bc15b8b
MK
75
76The calculation is performed without undue overflow or underflow
77during the intermediate steps of the calculation.
78.\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
79.\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
80.SH RETURN VALUE
81On success, these functions return the length of a right-angled triangle
82with sides of length
83.I x
e49f411f 84and
6bc15b8b
MK
85.IR y .
86
87If
88.I x
89or
90.I y
91is an infinity,
92positive infinity is returned.
93
94If
95.I x
96or
97.I y
98is a NaN,
99and the other argument is not an infinity,
100a NaN is returned.
101
102If the result overflows,
efe294cb 103a range error occurs,
6bc15b8b
MK
104and the functions return
105.BR HUGE_VAL ,
106.BR HUGE_VALF ,
107or
108.BR HUGE_VALL ,
109respectively.
110
111If both arguments are subnormal, and the result is subnormal,
112.\" Actually, could the result not be subnormal if both arguments
113.\" are subnormal? I think not -- mtk, Jul 2008
efe294cb 114a range error occurs,
6bc15b8b
MK
115and the correct result is returned.
116.SH ERRORS
117See
118.BR math_error (7)
119for information on how to determine whether an error has occurred
120when calling these functions.
121.PP
122The following errors can occur:
123.TP
124Range error: result overflow
125.I errno
126is set to
127.BR ERANGE .
128An overflow floating-point exception
129.RB ( FE_OVERFLOW )
130is raised.
131.TP
132Range error: result underflow
133.\" .I errno
134.\" is set to
135.\" .BR ERANGE .
136An underflow floating-point exception
137.RB ( FE_UNDERFLOW )
138is raised.
139.IP
140These functions do not set
141.IR errno
142for this case.
143.\" FIXME . Is it intentional that these functions do not set errno?
144.\" They do set errno for the overflow case.
145.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795
146.SH "CONFORMING TO"
147C99, POSIX.1-2001.
148The variant returning
149.I double
150also conforms to
151SVr4, 4.3BSD.
fea681da
MK
152.SH "SEE ALSO"
153.BR cabs (3),
154.BR sqrt (3)