hypot, hypotl
raw OCR
Calculates hypotenuse of a right triangle.
Defined in header <math.h>
Syntax
#include <math.h>
double hypot(double x, double y);
long double hypotldong double x, long double y);
hypot calculates the value z where
z* = x* + y*
and
2>=0
This is equivalent to the length of the hypotenuse of a right triangle, if the
lengths of the two sides are x and y.
hyptol is the long double version; it takes long double arguments and
returns a long double result.
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| hypot | ■ | ■ | ■ | ||
| hypofi | ■ | ■ |
Return value
On success, these functions return z, a double (hypot) or a long double) (hypoti). On error (such as an overflow), they set the global variable errno to
ERANGE Result out of range
| and return the value HUGE_VAL | (hypot) or _LHUGE_VAL) | (hypoti). |
Error handling for these routines can be modified through the functions matherr and _matherrl.
Example
ilnclude <stdio.h>
#include <math.h>
int main (void)
{
double result, x = 3.( y = 4.
result = hypot (x, y);
printfC'The hypotenuse is: Dlf\n", result)
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Extraction notes
- heading `hypot, hypoti` read as `hypot, hypotl`
Stable link: /3.1/math.h/hypot/
· short form /3.1/hypot/