错误说明

有关如何确定调用这些函数时是否发生错误的信息,请参见math_error(7)。

可能会发生以下错误:

Domain error: xis a NaN or infinite, or the rounded value is too large
引发了无效的浮点异常(FE_INVALID)。

这些功能未设置errno。

另外参见

ceil(3),floor(3),lrint(3),neighborint(3),rint(3),round(3)

名称

lround,lroundf,lroundl,llround,llroundf,llroundl-舍入到最接近的整数

遵循规范

C99,POSIX.1-2001,POSIX.1-2008。

说明

这些函数将其参数四舍五入为最接近的整数值,无论当前舍入方向如何,都将中值舍入为零,而不是四舍五入(请参阅fenv(3))。

请注意,与round(3)和ceil(3)函数不同,这些函数的返回类型与参数的返回类型不同。

出版信息

这个页面是Linux手册页项目5.08版的一部分。有关项目的说明、有关报告错误的信息以及此页面的最新版本,请访问https://www.kernel.org/doc/man-pages/

LROUND - Linux手册页

Linux程序员手册 第3部分
更新日期: 2017-09-15

属性

有关本节中使用的术语的说明,请参见attribute(7)。

InterfaceAttributeValue
lround(),lroundf(),lroundl(),
llround(),llroundf(),llroundl()
Thread safetyMT-Safe

版本

这些功能首先出现在2.1版的glibc中。

返回值

这些函数返回舍入的整数值。

如果x为NaN或无穷大,或者舍入后的值太大而无法存储为long(对于ll *函数,则为long long),则将发生域错误,并且未指定返回值。

语法

#include <math.h>

long int lround(double x);
long int lroundf(float x);
long int lroundl(long double x);

long long int llround(double x);
long long int llroundf(float x);
long long int llroundl(long double x);

与-lm链接。

glibc的功能测试宏要求(请参阅feature_test_macros(7)):

上面显示的所有功能:

_ISOC99_SOURCE || _POSIX_C_SOURCE>= 200112L
日期:2019-08-20 18:00:49 来源:oir作者:oir