NEARBYINT(3) | Library Functions Manual | NEARBYINT(3) |
nearbyint
— round
to integral value in floating-point format
#include
<math.h>
double
nearbyint
(double
x);
long double
nearbyintl
(long
double x);
float
nearbyintf
(float
x);
The
nearbyint
()
functions return the integral value (represented as a double precision
number) nearest to x according to the prevailing
rounding mode.
nearbyint
()
is the same as
rint
(),
except that nearbyint is guaranteed never to set floating point flags or
trigger floating point exceptions (which are disabled by default).
rint
() is typically much more performant than
nearbyint
() if the application does not depend on
flags being preserved.
nearbyint
(±0)
returns ±0 for all rounding modes.
nearbyint
(±infinity)
returns ±infinity for all rounding modes.
rint(3) ceil(3) floor(3) round(3) trunc(3) lround(3) lrint(3) llround(3) llrint(3) math(3)
The nearbyint
() functions conform to
ISO/IEC 9899:2011.
July 1, 2008 | macOS 14.6 |