rint(), rintf(), rintl() — Round to nearest integral value

Standards

Standards / Extensions C or C++ Dependencies

XPG4.2
C99
Single UNIX Specification, Version 3
C++ TR1 C99

both  

Format

#define _XOPEN_SOURCE_EXTENDED 1
#include <math.h>

double rint(double x);
C99
#define _ISOC99_SOURCE
#include <math.h>

float rintf(float x);
long double rintl(long double x);
C++ TR1 C99
#define _TR1_C99
#include <math.h>

float rint(float x); 
long double rint(long double x);

General description

The rint() functions return the integral value (represented in a floating-point mode) nearest x using the round to nearest mode and may raise the "inexact" floating-point exception if the result differs in value from the argument.
Note: The following table shows the viable formats for these functions. See IEEE binary floating-point for more information about IEEE Binary Floating-Point.
Function Hex IEEE
rint X X
rintf X X
rintl X X

Returned value

rint() is always successful in IEEE.

Special behavior for hex: The rint() functions always round toward zero in hexadecimal math.

Related information