C99 | long long int llround (double x);
long long int llroundf (float x); long long int llroundl (long double x); |
C++11 | long long int llround (double x);
long long int llround (float x); long long int llround (long double x); long long int llround (T x); // additional overloads for integral types |
C99 | 头文件<tgmath.h> 提供了该函数的类型泛型宏版本。 |
C++11 | 这个头文件(<cmath>)为整型提供了额外的重载:
这些重载有效地在计算之前将x转换为double(在T是任何整型时定义)。
|
/* llround example */ #include <stdio.h> /* printf */ #include <math.h> /* llround */ int main () { printf ( "llround (2.3) = %lld\n", llround(2.3) ); printf ( "llround (3.8) = %lld\n", llround(3.8) ); printf ( "llround (-2.3) = %lld\n", llround(-2.3) ); printf ( "llround (-3.8) = %lld\n", llround(-3.8) ); return 0; } |
Rounding using to-nearest rounding: llround (2.3) = 2 llround (3.8) = 4 llround (-2.3) = -2 llround (-3.8) = -4 |
ceil | 向上舍入(function ) |
floor | 向下舍入(function ) |
trunc | 截断(function ) |
llrint | 舍入并强制转换为long long int(function ) |
nearbyint | 舍入到最近的整数值(function ) |
round | 就近舍入(function ) |
lround | 舍入到最接近的值并转换为long integer(function ) |