约 1229 字

约 6 分钟

#C 语言标准库函数 decodebind32

#include <math.h>

void decodebind32(_Decimal32 *restrict xptr, const unsigned char encptr[restrict static 4]);

说明

将字节数组解释为 IEC 60559 的二进制整数系数编码。

字节顺序由 __STDC_ENDIAN_NATIVE__ 决定。转换保留数值,不引发浮点异常。非规范输入的表示是否规范化取决于实现。

自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。

参数

  • xptr - 指向接收结果的十进制浮点对象。
  • encptr - 至少含 4 个元素的只读数组,每个元素使用 8 位。

返回值

  • 无返回值。转换结果由输出参数交付。

#示例

使用 GCC 时,在链接命令末尾添加 -lm。

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

int main(void)
{
    const unsigned char encoded[4] = {0};
    _Decimal32 value;
    decodebind32(&value, encoded);
    printf("%Lg\n", (long double)value);
    return 0;
}

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28