lrint, lrintf, lrintl, llrint, llrintf, llrintl
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at lrint, lrintf, lrintl, llrint, llrintf, llrintl.
Rounds the specified floating-point value to the nearest integral value, by using the current rounding mode and direction.
long int lrint( double x ); long int lrint( float x ); //C++ only long int lrint( long double x ); //C++ only long int lrintf( float x ); long int lrintl( long double x ); long long int llrint( double x ); long long int llrint( float x ); //C++ only long long int llrint( long double x ); //C++ only long long int llrintf( float x ); long long int llrintl( long double x );
Parameters
[in] x
the value to round.
If successful, returns the rounded integral value of x.
| Issue | Return |
|---|---|
x is outside the range of the return typex = ±∞x = NaN | Raises FE_INVALID and returns zero (0). |
Because C++ allows overloading, you can call overloads of lrint and llrint that take float and long double types. In a C program, lrint and llrint always take a double.
If x does not represent the floating-point equivalent of an integral value, these functions raise FE_INEXACT.
Microsoft specific: When the result is outside the range of the return type, or when the parameter is a NaN or infinity, the return value is implementation defined. The Microsoft compiler returns a zero (0) value.
| Function | C header | C++ header |
|---|---|---|
lrint, lrintf, lrintl, llrint, llrintf, llrintl | <math.h> | <cmath> |
For additional compatibility information, see Compatibility.