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

quantumd32函数


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

描述:

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

该函数计算有限参数x的量子。如果参数x是无穷大,则结果是正无穷大。


参数:
_Decimal32 x

参数为_Decimal32类型的浮点数。


返回值:

函数返回参数x的量子。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        _Decimal32 x = 1.00df;
         
        printf("The quantum of %.2Hf is %.2Hf\n", x, quantumd32(x));
    #else
        puts("The implementation does not support quantumd32 function.");
    #endif

    return 0;
}

可能输出:

The quantum of 1.00 is 0.01.

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


相关内容:
quantumd64 _Decimal64类型的计算有限实参量子的函数。
quantumd128 _Decimal128类型的计算有限实参量子的函数。


主要参考资料:

1、ISO/IEC 9899:2024