LLROUND(3P)
π LLROUND β POSIX Programmer's Manual, section 3P π
okay bestie, so this is a page from the POSIX Programmer's Manual, and it's giving llround(3P) energy. β¨
π«Ά PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux at all. π so like, check first, fr fr.
πΈ NAME πΈ
llround, llroundf, llroundl β round to nearest integer value
β¨ SYNOPSIS β¨
#include <math.h>
long long llround(double x);
long long llroundf(float x);
long long llroundl(long double x);
three lil besties, one job π
π DESCRIPTION π
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1β2017 defers to the ISO C standard. periodt.
These functions shall round their argument to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding direction. so like, 2.5 goes up, -2.5 goes down-down, and nothing about your current rounding mode changes that. iconic behavior honestly. π
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. π that's your vibe check, do it before and after.
π RETURN VALUE π
Upon successful completion, these functions shall return the rounded integer value. slay. π₯³
- If
xisNaN, a domain error shall occur, and an unspecified value is returned. - If
xis+Inf, a domain error shall occur and an unspecified value is returned. - If
xis-Inf, a domain error shall occur and an unspecified value is returned. - If the correct value is positive and too large to represent as a
long long, an unspecified value shall be returned. On systems that support the IEC 60559 Floating-Point option, a domain error shall occur; otherwise, a domain error may occur. - If the correct value is negative and too large to represent as a
long long, an unspecified value shall be returned. On systems that support the IEC 60559 Floating-Point option, a domain error shall occur; otherwise, a domain error may occur.
bestie if you're seeing NaN or an infinity go in here, the value coming back is literally unspecified. not a vibe. do not trust it. π©
π ERRORS π
These functions shall fail if:
- Domain Error β The
xargument isNaNorΒ±Inf, or the correct value is not representable as an integer.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
- If the integer expression
These functions may fail if:
- Domain Error β The correct value is not representable as an integer.
- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[EDOM]. If the integer expression(math_errhandling & MATH_ERREXCEPT)is non-zero, then the invalid floating-point exception shall be raised.
- If the integer expression
The following sections are informative. π«Ά (yes, everything from here down is the chill, non-normative part)
π EXAMPLES π
None. not a single one π iconic of them honestly.
π APPLICATION USAGE π
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. no cap.
π RATIONALE π
These functions differ from the llrint() functions in that the default rounding direction for the llround() functions round halfway cases away from zero and need not raise the inexact floating-point exception for non-integer arguments that round to within the range of the return type. so that's the whole tea: llround is the chaotic one that doesn't care about your rounding direction, and it's not gonna make a whole scene about the inexact exception either. π
π¦ FUTURE DIRECTIONS π¦
None. we're stable, we're thriving, we're not going anywhere. β¨
π₯ SEE ALSO π₯
feclearexcept()fetestexcept()lround()
The Base Definitions volume of POSIX.1β2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, <math.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay and that's the whole page bestie, that's it, that's the tea π this absolute banger was brought to you by IEEE and The Open Group, dated 2017, and honestly? they ate. πβ¨ππ¦πΈπ π«Άπ
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms