约 1313 字

约 7 分钟

#C 语言标准库函数 fmind64

#include <math.h>

_Decimal64 fmind64(_Decimal64 x, _Decimal64 y);

说明

比较两个实浮点数,选择较小值。只有一个参数为 NaN 时选择另一个参数。

对大小相等的两个带符号零,基本接口不保证固定的符号。

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

参数

  • x - 参与运算的实浮点值。
  • y - 第二个实浮点操作数。

返回值

  • 选择的较小值。两个参数均为 NaN 时返回 NaN。

#示例

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

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

int main(void)
{
    _Decimal64 computed = fmind64(-7.0dd, 3.0dd);
    printf("%Lg\n", (long double)computed);
    return !(computed == -7.0dd);
}

运行结果。

-7

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28