Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

exp(3)

isnan(3)

math(3)

sqrt(3)

hypot(3)  —  Subroutines

Digital

NAME

hypot, cabs, fhypot, fcabs − Computes Euclidean distance function and complex absolute value

LIBRARY

Math Library (libm.a)

SYNOPSIS

#include <math.h> double hypot (
double x, double y); double cabs (
struct {double x, y;} z ); float fhypot (
float x, float y); float fcabs (
struct {float x, y;} z);

PARAMETERS

xSpecifies a double or float value, depending on the function. 

ySpecifies a double or float value, depending on the function. 

zSpecifies a structure that has two double or float elements, depending on the function. 

DESCRIPTION

These functions compute the length of the hypotenuse of a right angled triangle with the formula sqrt(x∗x+y∗y). 

NOTES

The hypot(), fhypot(), cabs(), and fcabs() functions return sqrt(x∗x+y∗y) computed in such a way that underflow does not occur, and overflow occurs only if overflow is appropriate for the final result. 

The fhypot() and fcabs() functions are the same functions as hypot() and cabs() but for the float data type. 

hypot(infinity,v) = hypot(v,infinity) = +infinity for all v, including NaN (Not a Number). 

Roundoff errors are below 0.97 ulp (Units in the Last Place).  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 cabs() that is provided in the comments of the cabs.c file; the error of this version of cabs() can exceed 1.2 ulp. 

As might be expected, hypot(v,NaN) and hypot(NaN,v) and NaN for all finite v. You might be surprised at first to discover that hypot(+infinity,NaN)=+infinity. This is intentional; it occurs because hypot(+infinity,NaN)=+infinity for all v, finite or infinite. Therefore, hypot(infinity,v) is independent of v.  The IEEE NaN value is designed to disappear when it turns out to be irrelevant, as it does in hypot(infinity,NaN). 

AES Support Level:
Trial use (hypot())

ERRORS

If the hypot() function fails, errno may be set to one of the following values:

[EDOM]The value of x or y is NaN. 

[ERANGE]The value to be returned would cause overflow. 

ENVIRONMENT

The System V habitat does not provide float functions (fhypot() and fcabs()). Furthermore, the hypot() function returns HUGE and sets errno to ERANGE when the correct value would overflow. 

In the System V habitat, error-handling procedures can be changed with the matherr() function. 

RELATED INFORMATION

Functions: exp(3), isnan(3), math(3), sqrt(3)
 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026