LROUND(3POSIX)
πΈ LROUND(3POSIX) β the POSIX Programmer's Manual, bestie edition πΈ
okay so first things first, this page lives in the POSIX Programmer's Manual, and there's a lil warning label on it: the Linux implementation of this interface may differ (so go peek at the corresponding Linux manual page for the tea on Linux behavior), or honestly the interface might just not be implemented on Linux at all. π
β¨ 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. π
π NAME π
lround, lroundf, lroundl β round to nearest integer value. periodt.
π SYNOPSIS π
#include <math.h>
long lround(double x);
long lroundf(float x);
long lroundl(long double x);
π¦ DESCRIPTION π¦
The functionality described on this reference page is aligned with the ISO C standard. If there's any conflict between what's written here and the ISO C standard, that conflict is not on purpose, fr fr. This volume of POSIX.1β2017 defers to the ISO C standard. π
These functions shall round their argument to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding direction. like, it does NOT care what rounding direction you set, it's doing its own thing. main character energy 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, bestie. π
β 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, an unspecified value shall be returned. On systems that support the IEC 60559 Floating-Point option, a domain shall occur; otherwise, a domain error may occur. π - If the correct value is negative and too large to represent as a
long, an unspecified value shall be returned. On systems that support the IEC 60559 Floating-Point option, a domain shall occur; otherwise, a domain error may occur. π
π 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
heads up bestie: the following sections are informative. they're the bonus content, not the rules. π«Ά
πΈ EXAMPLES πΈ
None. that's it, that's the section. the void. nothing. π
π§ 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 lrint() functions in the default rounding direction β with the lround() functions rounding halfway cases away from zero and needing not to raise the inexact floating-point exception for non-integer arguments that round to within the range of the return type. iykyk. π
π FUTURE DIRECTIONS π
None. (the future is a mystery, but this section is not π¦)
π SEE ALSO π
feclearexcept()fetestexcept()llround()
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 . π
k that's the whole page bestie, love that for you π this lil drop was brought to you by IEEE/The Open Group, dated 2017, filed under LROUND(3POSIX). go round some numbers, you got this. π«Άβ¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms