# 2.11BSD/src/man/man3/hypot.3

Compare this file to the similar file:
Show the results in this format:

```.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved.  The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\"
.\"	@(#)hypot.3m	6.5 (Berkeley) 5/12/86
.\"
.TH HYPOT 3M  "May 12, 1986"
.UC 4
.ds up \fIulp\fR
.ds nn \fINaN\fR
.SH NAME
hypot, cabs \- Euclidean distance, complex absolute value
.SH SYNOPSIS
.nf
.B #include <math.h>
.PP
.B double hypot(x,y)
.B double x,y;
.PP
.B double cabs(z)
.B struct {double x,y;} z;
.fi
.SH DESCRIPTION
Hypot(x,y) and cabs(x,y) return sqrt(x\(**x+y\(**y)
computed in such a way that underflow will not happen, and overflow
occurs only if the final result deserves it.
.PP
.if n \
hypot(infinity,v) = hypot(v,infinity) = +infinity for all v,
.if t \
hypot(\(if,v) = hypot(v,\(if) = +\(if for all v,
including \*(nn.
.SH ERROR (due to Roundoff, etc.)
Below 0.97 \*(ups.  Consequently hypot(5.0,12.0)\0=\013.0 exactly;
in general, hypot and cabs return an integer whenever an
integer might be expected.
.PP
The same cannot be said for the shorter and faster version of hypot
and cabs that is provided in the comments in cabs.c; its error can
exceed 1.2 \*(ups.
.SH NOTES
As might be expected, hypot(v,\*(nn) and hypot(\*(nn,v) are \*(nn for all
\fIfinite\fR v; with "reserved operand" in place of "\*(nn", the
same is true on a VAX.  But programmers on machines other than a VAX
(it has no
.if n \
infinity)
.if t \
\(if)
might be surprised at first to discover that
.if n \
hypot(\(+-infinity,\*(nn) = +infinity.
.if t \
hypot(\(+-\(if,\*(nn) = +\(if.
This is intentional; it happens because
.if n \
hypot(infinity,v) = +infinity
.if t \
hypot(\(if,v) = +\(if
for \fIall\fR v, finite or infinite.
Hence
.if n \
hypot(infinity,v)
.if t \
hypot(\(if,v)
is independent of v.
Unlike the reserved operand on a VAX, the IEEE \*(nn is designed to
disappear when it turns out to be irrelevant, as it does in
.if n \
hypot(infinity,\*(nn).
.if t \
hypot(\(if,\*(nn).
.SH SEE ALSO
math(3M), sqrt(3M)
.SH AUTHOR
W. Kahan
```