1 '\" te
   2 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
   3 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
   4 .\" Portions Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
   5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at 
   6 .\" http://www.opengroup.org/bookstore/.
   7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   8 .\"  This notice shall appear on any product containing this material.
   9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  12 .TH hypot 3M "1 Sep 2002" "SunOS 5.11" "Mathematical Library Functions"
  13 .SH NAME
  14 hypot, hypotf, hypotl \- Euclidean distance function
  15 .SH SYNOPSIS
  16 .LP
  17 .nf
  18 c99 [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ]
  19 #include <math.h>
  20 
  21 \fBdouble\fR \fBhypot\fR(\fBdouble\fR \fIx\fR, \fBdouble\fR \fIy\fR);
  22 .fi
  23 
  24 .LP
  25 .nf
  26 \fBfloat\fR \fBhypotf\fR(\fBfloat\fR \fIx\fR, \fBfloat\fR \fIy\fR);
  27 .fi
  28 
  29 .LP
  30 .nf
  31 \fBlong double\fR \fBhypotl\fR(\fBlong double\fR \fIx\fR, \fBlong double\fR \fIy\fR);
  32 .fi
  33 
  34 .SH DESCRIPTION
  35 .sp
  36 .LP
  37 These functions compute the length of the square root of \fIx\fR^2 + \fIy\fR^2
  38 without undue overflow or underflow.
  39 .SH RETURN VALUES
  40 .sp
  41 .LP
  42 Upon successful completion, these functions return the length of the hypotenuse
  43 of a right angled triangle with sides of length \fIx\fR^2 and \fIy\fR^2.
  44 .sp
  45 .LP
  46 If the correct value would cause overflow, a range error occurs and
  47 \fBhypot()\fR, \fBhypotf()\fR, and \fBhypotl()\fR return the value of the macro
  48 \fBHUGE_VAL\fR, \fBHUGE_VALF\fR, and \fBHUGE_VALL\fR, respectively.
  49 .sp
  50 .LP
  51 If \fIx\fR or \fIy\fR is \(+-Inf, +Inf is returned even if one of \fIx\fR or
  52 \fIy\fR is NaN.
  53 .sp
  54 .LP
  55 If \fIx\fR or \fIy\fR is NaN and the other is not \(+-Inf, a NaN is returned.
  56 .SH ERRORS
  57 .sp
  58 .LP
  59 These functions will fail if:
  60 .sp
  61 .ne 2
  62 .mk
  63 .na
  64 \fBRange Error\fR
  65 .ad
  66 .RS 15n
  67 .rt  
  68 The result overflows.
  69 .sp
  70 If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is
  71 non-zero, the overflow floating-point exception is raised.
  72 .RE
  73 
  74 .SH USAGE
  75 .sp
  76 .LP
  77 \fBhypot\fR(\fIx\fR,\fIy\fR), \fBhypot\fR(\fIy\fR,\fIx\fR), and
  78 \fBhypot\fR(\fIx\fR, \(mi\fIy\fR) are equivalent.
  79 .sp
  80 .LP
  81 \fBhypot\fR(\fIx\fR, \(+-0) is equivalent to \fBfabs\fR(\fIx\fR).
  82 .sp
  83 .LP
  84 These functions takes precautions against underflow and overflow during
  85 intermediate steps of the computation.
  86 .sp
  87 .LP
  88 An application wanting to check for exceptions should call
  89 \fBfeclearexcept\fR(\fBFE_ALL_EXCEPT\fR) before calling these functions. On
  90 return, if \fBfetestexcept\fR(\fBFE_INVALID\fR | \fBFE_DIVBYZERO\fR |
  91 \fBFE_OVERFLOW\fR | \fBFE_UNDERFLOW\fR) is non-zero, an exception has been
  92 raised. An application should either examine the return value or check the
  93 floating point exception flags to detect exceptions.
  94 .SH ATTRIBUTES
  95 .sp
  96 .LP
  97 See \fBattributes\fR(5) for descriptions of the following attributes:
  98 .sp
  99 
 100 .sp
 101 .TS
 102 tab() box;
 103 cw(2.75i) |cw(2.75i) 
 104 lw(2.75i) |lw(2.75i) 
 105 .
 106 ATTRIBUTE TYPEATTRIBUTE VALUE
 107 _
 108 Interface StabilityStandard
 109 _
 110 MT-LevelMT-Safe
 111 .TE
 112 
 113 .SH SEE ALSO
 114 .sp
 115 .LP
 116 \fBfabs\fR(3M), \fBfeclearexcept\fR(3M), \fBfetestexcept\fR(3M),
 117 \fBisnan\fR(3M), \fBmath.h\fR(3HEAD), \fBsqrt\fR(3M), \fBattributes\fR(5),
 118 \fBstandards\fR(5)