nearbyint(), nearbyintf(), nearbyintl()

Return a rounded integer value

Synopsis:

#include <math.h>

double nearbyint( double x);

float nearbyintf( float x);

long double nearbyintl( long double x);

Arguments:

x
The number that you want to round.

Library:

libm

Use the -l m option to qcc to link against this library.

Description:

The nearbyint(), nearbyintf(), and nearbyintl() functions round their argument to an integer value in floating-point format, using the current rounding direction and without raising the inexact floating-point exception.

To check for error situations, use feclearexcept() and fetestexcept(). For example:

Returns:

The rounded integer value, with the same sign as x.

If x is: These functions return: Errors:
±0.0 ±0.0
±Inf x
NaN NaN

These functions raise FE_INEXACT if the FPU reports that the result can't be exactly represented as a floating-point number.

Classification:

ANSI, POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes