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

compoundnd128函数


概要:
#include <math.h>
#ifdef __STDC_IEC_60559_DFP__
    _Decimal128 compoundnd128(_Decimal128 x,long long int n);
#endif 

描述:

该函数计算(1+x)n的值。

如果x<-1,会发生域错误。取决于n的值,如果正有限的x值太大,或者x非常接近但不等于-1时,会发生范围错误。如果x=-1,并且n<0,可能发生极点错误。


参数:
_Decimal128 x

参数为_Decimal128类型的浮点数。

long long int n

参数为long long int类型的整数。


返回值:

函数返回(1+x)n。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        _Decimal128 x = 5.0dl,y;
        long long int n = 2LL;

        y = compoundnd128(x,n);
        printf("compoundnd128(%.6DDf,%lld) = %.6DDf\n", x,n,y);
    #else
        puts("The implementation does not support compoundnd128 function.");
    #endif

    return 0;
}

输出:

The implementation does not support compoundnd128 function.


相关内容:
compoundn double类型的返回(1+x)n的函数。
compoundnl long double类型的返回(1+x)n的函数。
compoundnf float类型的返回(1+x)n的函数。
compoundnd32 _Decimal32类型的返回(1+x)n的函数。
compoundnd64 _Decimal64类型的返回(1+x)n的函数。


主要参考资料:

1、ISO/IEC 9899:2024