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