NEARBYINT(3POSIX)
π NEARBYINT(3POSIX) β POSIX Programmer's Manual π
okay bestie so this is one of those pages from the POSIX Programmer's Manual, and the vibe is very much "the C standard already said it, we're just relaying the message." β¨
π¨ 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. so likeβ¦ check your local situation, no cap π
πΈ NAME
nearbyint, nearbyintf, nearbyintl β floating-point rounding functions
β¨ SYNOPSIS
#include <math.h>
double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(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. (translation: the ISO C standard is the main character here, we're just the group chat relaying the gossip π )
These functions shall round their argument to an integer value in floating-point format, using the current rounding direction and without raising the inexact floating-point exception. so it rounds, it respects whatever rounding direction is currently set, and it stays quiet β no inexact exception drama π
π RETURN VALUE
Upon successful completion, these functions shall return the rounded integer value. The result shall have the same sign as x. π«Ά
- If x is NaN, a NaN shall be returned.
- If x is Β±0, Β±0 shall be returned.
- If x is Β±Inf, x shall be returned.
π ERRORS
No errors are defined. iconic behaviour honestly, zero problems, zero notes π
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.
lowkey important: don't just yeet that return value into an integer type without checking first, or you get undefined results from integer overflow. test it first, bestie π«Ά
π RATIONALE
None.
β FUTURE DIRECTIONS
None.
π SEE ALSO
feclearexcept()fetestexcept()
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 .
and that's the whole page, bestie β brought to you by IEEE/The Open Group, 2017 edition. stay rounded, stay unexceptional (in the floating-point sense), and go read your local math.h before you ship anything πβ¨ππ¦
π¦ 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