lround(3)
π lround(3) β the "round it, but give me an actual integer" girlies π
okay bestie so this is a page from the Library Functions Manual, and it's all about the lround family β the ones who take your float and hand you back a whole number, no decimal drama, no cap. β¨
π NAME π
lround, lroundf, lroundl, llround, llroundf, llroundl β round to nearest integer
π LIBRARY π
Math library (libm, -lm)
like she lives in libm, so if you're linking, don't forget your -lm, bestie, or she's gonna ghost you. π«Ά
β¨ SYNOPSIS β¨
#include <math.h>
long lround(double x);
long lroundf(float x);
long lroundl(long double x);
long long llround(double x);
long long llroundf(float x);
long long llroundl(long double x);
πΈ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): πΈ
All functions shown above:
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
so yeah, you gotta define that or the compiler is gonna be like "who?? never heard of her." π
π DESCRIPTION π
These functions round their argument to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding direction (see fenv(3)).
okay that's the tea right there β halfway cases go away from zero, always, no matter what your current rounding direction is doing. she does NOT check the vibe of fenv(3). she has her own agenda. periodt. π
Note that unlike the round(3) and ceil(3), functions, the return type of these functions differs from that of their arguments.
that's literally the whole plot twist: she does not return the same type you handed her. that's the entire point of her existence. it's giving "i changed, bestie." π¦
π RETURN VALUE π
These functions return the rounded integer value.
If x is a NaN or an infinity, or the rounded value is too large to be stored in a long (long long in the case of the ll* functions), then a domain error occurs, and the return value is unspecified.
π¨ bestie listen β NaN, infinity, or a number so big it won't fit in along(orlong longfor thell*crew)? that's a domain error and the return value is unspecified. unspecified means don't trust it, do not pass go, do not collect. π
π ERRORS π
See math_error(7) for information on how to determine whether an error has occurred when calling these functions.
The following errors can occur:
- Domain error:
xis a NaN or infinite, or the rounded value is too large β An invalid floating-point exception (FE_INVALID) is raised.
These functions do not set errno.
ngl, that last line is the one that gets people. no errno for you, so don't go checking it and feeling confused. π this is why math_error(7) exists, go read her.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
lround(),lroundf(),lroundl(),llround(),llroundf(),llroundl() - Attribute: Thread safety
- Value: MT-Safe
MT-Safe, meaning she's safe to hang with from multiple threads at once. multithreaded icon behavior, honestly. π
β STANDARDS β
C11, POSIX.1-2008.
π§ HISTORY π§
glibc 2.1. C99, POSIX.1-2001.
she's been around. she's a legacy icon, a vintage queen, and she's still slaying. β¨
π₯ SEE ALSO π₯
ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
like her whole friend group, go say hi, they're all doing similar-but-different things and yes you have to know the difference, sorry bestie, that's the assignment. π
πΈ cute lil sign-off: this page is from Linux man-pages 6.20, dated 2026-02-08, and it's all aboutlround(3)β round to nearest integer, halfway cases away from zero, and that's onlround(3)π ππ¦
π¦ 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 2001, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms