当前位置: C语言 -- 标准库 -- <math.h> -- fmodd32

fmodd32函数


概要:
#include <math.h>
#ifdef __STDC_IEC_60559_DFP__
    _Decimal32 fmodd32(_Decimal32 x, _Decimal32 y);
#endif 

描述:

该函数计算表达式x/y的浮点余数。


参数:
_Decimal32 x

参数为_Decimal32类型的浮点数。

_Decimal32 y

参数为_Decimal32类型的浮点数。


返回值:

函数返回x-ny的值,其中n为整数;如果参数y为非0值,结果与参数x具有相同的符号,并且结果的绝对值小于参数y的绝对值。如果参数y为0,是发生域错误,还是返回0,将由实现定义。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
/*函数fmodd32范例*/

#include <math.h>
#include <stdio.h>

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        _Decimal32 x = -4.0df;
        _Decimal32 y = 5.0df;
        _Decimal32 z = 7.0df;
        
        printf("fmodd32(%.2Hf,%.2Hf) = %.2Hf\n", y, x, fmodd32(y,x));
        printf("fmodd32(%.2Hf,%.2Hf) = %.2Hf\n", z, x, fmodd32(z,x));
    #else
        puts("The implementation does not support fmodd32 function.");
    #endif

    return 0;
}

可能输出:

fmodd32(5.00,-4.00) = 1.00

fmodd32(7.00,-4.00) = 3.00

(注:编译时实现还未支持fmodd32函数。)


相关内容:
fmod double类型的计算余数函数。
fmodf float类型的计算余数函数。
fmodl long double类型的计算余数函数。
fmodd64 _Decimal64类型的计算余数函数。
fmodd128 _Decimal128类型的计算余数函数。


主要参考资料:

1、ISO/IEC 9899:2024