llround
基于当前舍入策略,以long long int形式返回舍入值。
接口定义
C interface:
long long int llroundf(float x);
long long int llround(double x);
long long int llroundl(long double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
|---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
返回x的舍入值,x ∈ (-inf, inf)。
依赖
C: "km.h"
示例
C interface:
// typical usage
printf("llround(0.0) = %lld\n", llround(0.0));
printf("llround(-0.0) = %lld\n", llround(-0.0));
printf("llround(1.0) = %lld\n", llround(1.0));
printf("llround(1.4) = %lld\n", llround(1.4));
printf("llround(1.5) = %lld\n", llround(1.5));
printf("llround(-3.0) = %lld\n", llround(-3.0));
printf("llround(-3.4) = %lld\n", llround(-3.4));
printf("llround(-3.5) = %lld\n", llround(-3.5));
result
/*
* llround(0.0) = 0
* llround(-0.0) = 0
* llround(1.0) = 1
* llround(1.4) = 1
* llround(1.5) = 2
* llround(-3.0) = -3
* llround(-3.4) = -3
* llround(-3.5) = -4
* */
父主题: 舍入函数