hypot(3m) — RISC
Name
hypot, cabs − Euclidean distance, complex absolute value
Syntax
#include <math.h>
double hypot(x,y)
double x,y;
float fhypot(float x, float y)
double cabs(z)
struct {double x,y;} z;
float fcabs(z)
struct {float x,y;} z;
Description
The hypot, fhypot, cabs, and fcabs functions return the following:
sqrt(x∗x+y∗y)
This computation prevents underflows and overflows only if the final result dictates it.
The functions fhypot and fcabs are equivalent to the hypot and cabs function with the exception of float data type.
Error
When rounding off, for example, below 0.97 ulps. Consequently hypot (5.0,12.0) = 13.0 exactly; in general, hypot and cabs return an integer whenever an integer might be expected.
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 ulps.
Return Values
If the correct value overflows, hypot and cabs return HUGE_VAL. If x or y is NaN, then NaN is returned.