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