RINT(3POSIX)
π RINT(3POSIX) β the POSIX Programmer's Manual, but make it cute π
okay bestie, so this page lives in the POSIX Programmer's Manual (that's the vibe), and it's all about rint, rintf and rintl. Let's get into it π«Ά
πΈ PROLOG πΈ
so like, first thing β this manual page is part of the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ (if you're on Linux, go consult the corresponding Linux manual page for the details of Linux behavior, fr), or honestly the interface may just not be implemented on Linux at all. π
β¨ NAME β¨
rint, rintf, rintl β round-to-nearest integral value. that's the whole assignment, and they ate π
π SYNOPSIS π
#include <math.h>
double rint(double x);
float rintf(float x);
long double rintl(long double x);
π¦ 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 return the integral value (represented as a double) nearest x in the direction of the current rounding mode. and yes bestie, the current rounding mode is implementation-defined β so it's giving "mystery", iykyk π
Here's the tea on which function rint() is basically cosplaying depending on your rounding mode:
- If the current rounding mode rounds toward negative infinity, then
rint()shall be equivalent tofloor(). - If the current rounding mode rounds toward positive infinity, then
rint()shall be equivalent toceil(). - If the current rounding mode rounds towards zero, then
rint()shall be equivalent totrunc(). - If the current rounding mode rounds towards nearest, then
rint()differs fromround()in that halfway cases are rounded to even rather than away from zero. (yes, that's the iconic "banker's rounding" moment π )
These functions differ from the nearbyint(), nearbyintf(), and nearbyintl() functions only in that they may raise the inexact floating-point exception if the result differs in value from the argument. so close, yet so different π
An application wishing to check for error situations should seterrnoto zero and callfeclearexcept(FE_ALL_EXCEPT)before calling these functions. On return, iferrnois non-zero orfetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)is non-zero, an error has occurred.
π RETURN VALUE π
Upon successful completion, these functions shall return the integer (represented as a double precision number) nearest x in the direction of the current rounding mode. The result shall have the same sign as x. slay.
- If
xis NaN, a NaN shall be returned. - If
xis Β±0 or Β±Inf,xshall be returned.
π ERRORS π
No errors are defined. iconic, honestly.
The following sections are informative.
π EXAMPLES π
None. (yeah... nothing here bestie, we move π§)
π APPLICATION USAGE π
The integral value returned by these functions need not be expressible as an intmax_t. The return value should be tested before assigning it to an integer type to avoid the undefined results of an integer overflow. so like, test before you commit, no cap π«Ά
β RATIONALE β
None.
π« FUTURE DIRECTIONS π«
None.
π₯ SEE ALSO π₯
abs()ceil()feclearexcept()fetestexcept()floor()isnan()nearbyint()
Also the Base Definitions volume of POSIX.1β2017, Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h>. go read those too, they're lowkey essential π
π 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 .
and that's the whole page bestie πΈ big thank-you to IEEE/The Open Group, 2017 for blessing us with this one β RINT(3POSIX), and she ATE π
β¨
π¦ 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