hypot(3)
๐ hypot(3) โ the "how far is it tho" math bestie โจ
okay so bestie, welcome to hypot(3) from the Library Functions Manual ๐ this is the math-girlie page and honestly? she ate. no cap.
๐ธ NAME ๐ธ
hypot, hypotf, hypotl โ the Euclidean distance function ๐
๐ LIBRARY ๐
Math library (libm, -lm) โ yeah you gotta link the math lib, she doesn't come free ๐ซถ
โจ SYNOPSIS โจ
#include <math.h>
double hypot(double x, double y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);
๐ง Feature Test Macro Requirements for glibc (iykyk, see feature_test_macros(7))
hypot():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| _XOPEN_SOURCE
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
hypotf(), hypotl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
bestie note: the difference between those two blocks is literally just the_XOPEN_SOURCEline and it's ONLY inhypot(). not me double-checking that five times ๐ anyway, copy them exactly, they're load-bearing.
๐ DESCRIPTION ๐
These functions return sqrt(x*x+y*y). ๐งฎโจ
So basically: it's the length of the hypotenuse of a right-angled triangle whose sides are x and y long. OR, lowkey the same thing, it's the distance from the point (x,y) to the origin. same vibe, different outfit ๐
The calculation is performed without undue overflow or underflow during the intermediate steps of the calculation. <- this is the whole reason hypot exists and isn't just you typing sqrt(x*x+y*y) by hand, bestie. she's careful. she's got main character energy. ๐
๐ฆ RETURN VALUE ๐ฆ
On success, these functions return the length of the hypotenuse of a right-angled triangle with sides of length x and y. easy, iconic, no notes โจ
If x or y is an infinity, positive infinity is returned. โพ๏ธ
If x or y is a NaN, and the other argument is not an infinity, a NaN is returned. ๐ซ
If the result overflows, a range error occurs, and the functions return HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively. ๐ญ
If both arguments are subnormal, and the result is subnormal, a range error occurs, and the correct result is returned. yes bestie, error AND correct answer at the same time, she's multitasking ๐
๐ ERRORS ๐
See math_error(7) for the deets on how to figure out whether an error actually happened when you called these functions.
The following errors can occur:
- Range error: result overflow โ
errnois set toERANGE. An overflow floating-point exception (FE_OVERFLOW) is raised. ๐ฅ - Range error: result underflow โ An underflow floating-point exception (
FE_UNDERFLOW) is raised.
These functions do not set errno for this case. not me checking errno for no reason ๐
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
- Interface:
hypot(),hypotf(),hypotl() - Attribute: Thread safety
- Value:
MT-Safe๐ (she's safe to use across threads, periodt)
โญ STANDARDS โญ
C11, POSIX.1-2008.
๐ HISTORY ๐
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD. yes she's old money AND new money ๐
๐ SEE ALSO ๐
okay that's the whole page bestie, go forth and compute your distances the safe way ๐ธ๐ฆโจ
ciao for now, and remember this was served fresh from Linux man-pages 6.20, dated 2026-02-08 โ hypot(3), signing off ๐
๐๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms