#C 语言标准库函数 fmodl
#include <math.h>
long double fmodl(long double x, long double y);
说明
计算浮点除法的余数,商按向零舍入取整数。
除数为零或被除数为无穷时,可能报告定义域错误。
自 C99 起提供。
参数
x- 被除数。y- 除数。
返回值
- 余数,正常结果的绝对值小于除数的绝对值,符号与被除数一致。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
long double computed = fmodl(-7.5L, 2.0L);
printf("%Lg\n", (long double)computed);
return !(computed == -1.5);
}
运行结果。
-1.5
#相关接口
- 接口变体 fmod、fmodf、fmodd32、fmodd64、fmodd128
- 类型通用分派 fmod(类型通用宏)
- 相关操作 remainderl、remquol