OSDN Git Service

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