#C 语言标准库函数 decodebind128
#include <math.h>
void decodebind128(_Decimal128 *restrict xptr, const unsigned char encptr[restrict static 16]);
说明
将字节数组解释为 IEC 60559 的二进制整数系数编码。
字节顺序由 __STDC_ENDIAN_NATIVE__ 决定。转换保留数值,不引发浮点异常。非规范输入的表示是否规范化取决于实现。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
xptr- 指向接收结果的十进制浮点对象。encptr- 至少含 16 个元素的只读数组,每个元素使用 8 位。
返回值
- 无返回值。转换结果由输出参数交付。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
const unsigned char encoded[16] = {0};
_Decimal128 value;
decodebind128(&value, encoded);
printf("%Lg\n", (long double)value);
return 0;
}