Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 8

rint(), rintf()

Round to the nearest integral value

Synopsis:

#include <math.h>

double rint ( double x );

float rintf ( float 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 rint() and rintf() functions return the integral value nearest x in the direction of the current rounding mode.

If the current rounding mode rounds toward negative infinity, then rint() is identical to floor(). If the current rounding mode rounds toward positive infinity, then rint() is identical to ceil().

Returns:

An integer (represented as a double precision number) nearest x in the direction of the current rounding mode (IEEE754).

If x is: rint() returns:
±Infinity x
NAN NAN

Note: If an error occurs, these functions return 0, but this is also a valid mathematical result. If you want to check for errors, set errno to 0, call the function, and then check errno again. These functions don't change errno if no errors occurred.

Examples:

#include <stdio.h>
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <fpstatus.h>

int main(int argc, char** argv)
{
    double a, b;

    a = 0.7 ;
    b = rint(a);
    printf("Round Native mode %f -> %f \n", a, b);

    return(0);
}

Classification:

ANSI, POSIX 1003.1

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

See also:

ceil(), floor()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 183

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/r/rint.html on line 183