std::round,std::roundf,std::roundl,std::lround,std::lroundf,std::lroundl, (3) - Linux Manuals
std::round,std::roundf,std::roundl,std::lround,std::lroundf,std::lroundl,: std::round,std::roundf,std::roundl,std::lround,std::lroundf,std::lroundl,
NAME
std::round,std::roundf,std::roundl,std::lround,std::lroundf,std::lroundl, - std::round,std::roundf,std::roundl,std::lround,std::lroundf,std::lroundl,
Synopsis
Defined in header
float round
float roundf(
double round
long double round
long double roundl(
double round
long lround
long lroundf(
long lround
long lround
long lroundl(
long lround
long long llround
long long llroundf(
long long llround
long long llround
long long llroundl(
long long llround
1-3)
halfway cases away from zero, regardless of the current rounding mode.
5-7, 9-11)
halfway cases away from zero, regardless of the current rounding mode.
4,8,12)
integral type. Equivalent to 2), 6), or 10), respectively
double).
Parameters
arg - floating point value
Return value
If no errors occur, the nearest integer value to arg, rounding halfway cases away
from zero, is returned.
Return value
math-round away zero.svg
Argument
If a domain error occurs, an implementation-defined value is returned
Error handling
Errors are reported as specified in math_errhandling.
If the result of std::lround or std::llround is outside the range representable by
the return type, a domain error or a range error may occur.
If the implementation supports IEEE floating-point arithmetic
For the std::round function:
For std::lround and std::llround functions:
Notes
FE_INEXACT may be
non-integer finite value.
The largest representable floating-point values are exact integers in all standard
floating-point formats, so std::round never overflows on its own;
may overflow any integer type
variable.
POSIX specifies that all cases where std::lround or std::llround raise FE_INEXACT
are domain errors.
The double version of std::round behaves as if implemented as follows:
auto const save_round
std::fesetround(FE_TOWARDZERO);
result
std::fesetround(save_round);
Example
// Run this code