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

frexpd64函数


概要:
#include <math.h>
#ifdef __STDC_IEC_60559_DFP__
    _Decimal64 frexpd64(_Decimal64 value,int *p);
#endif 

描述:

该函数将浮点数分解为规格化小数(normalized fraction)和整数幂,并将整数幂存入参数p指向的对象中。

参数value可使用以下形式表示:

value=x×10(*p)

如果函数返回类型是十进制浮点类型(例如:_Decimal32、_Decimal64、_Decimal128。),指数是10的整数幂。


参数:
_Decimal64 value

参数为_Decimal64类型的浮点数。

int *p

参数为指向int类型对象的指针,整数幂值将存入指针指向的对象中。


返回值:

如果参数value不是浮点数,或者如果整数幂超出int类型所能表示的范围,结果是未指定的;否则函数返回x,如果函数返回类型是十进制浮点类型,x的绝对值在[1/10,1)区间内或者等于0,并且value=x×10(*p)。如果参数value值等于0,x和*p均为0。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        _Decimal64 value = 5.0dd;
        int exponent;

        printf("The normalized fraction is %.6Df.\n", frexpd64(value,&exponent));
        printf("The integral power is %d.\n", exponent);
    #else
        puts("The implementation does not support frexpd64 function.");
    #endif

    return 0;
}

输出:

The implementation does not support frexpd64 function.


相关内容:
frexp 将double类型浮点数分解为规格化小数和整数幂的函数。
frexpl 将long double类型浮点数分解为规格化小数和整数幂的函数。
frexpf 将float类型浮点数分解为规格化小数和整数幂的函数。
frexpd32 将_Decimal32类型浮点数分解为规格化小数和整数幂的函数。
frexpd128 将_Decimal128类型浮点数分解为规格化小数和整数幂的函数。


主要参考资料:

1、ISO/IEC 9899:2024