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

llquantexpd128函数


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

描述:

量子指数(quantum exponent):十进制浮点数中,表示最低有效位(最后一位小数)位置的指数。以1.23dl为例,量子为0.01,量子指数为-2。

该函数计算有限参数x的量子指数。

如果参数x是无穷大或者非数值,函数返回LLONG_MIN,同时引发FE_INVALID浮点异常,并发生域错误。


参数:
_Decimal128 x

参数为_Decimal128类型的浮点数。


返回值:

函数返回参数x的量子指数。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        _Decimal128 x = 1.00dl;
         
        printf("The quantum exponent of %.2DDf is %lld\n", x, llquantexpd128(x));
    #else
        puts("The implementation does not support llquantexpd128 function.");
    #endif

    return 0;
}

可能输出:

The quantum exponent of 1.00 is -2.

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


相关内容:
llquantexpd32 _Decimal32类型的计算有限实参量子指数的函数。
llquantexpd64 _Decimal64类型的计算有限实参量子指数的函数。


主要参考资料:

1、ISO/IEC 9899:2024