gpt4 book ai didi

c# - C# (.Net) 是否区分信号 NaN 和静默 NaN?

转载 作者:太空宇宙 更新时间:2023-11-03 13:09:27 27 4
gpt4 key购买 nike

C# 是否区分信号 NaN 和静默 NaN?

如果是这样,我如何调用两者并检查属性?

最佳答案

没有。我在规范或代码中找不到任何对 Quiet 或 Signaling NaN 的引用。

规范没有提到不同的 NaN 类型。来自 4.1.6 Floating point types :

The Not-a-Number value, often abbreviated NaN. NaN's are produced by invalid floating-point operations, such as dividing zero by zero.

源代码中的几个示例:

  • Double.NaN :

    public const double NaN = (double)0.0 / (double)0.0;
  • Double.IsNaN :

    return (*(UInt64*)(&d) & 0x7FFFFFFFFFFFFFFFL) > 0x7FF0000000000000L;
  • Math.IEEERemainder(double x, double y) :

    public static double IEEERemainder(double x, double y) {
    if (Double.IsNaN(x)) {
    return x; // IEEE 754-2008: NaN payload must be preserved
    }
    if (Double.IsNaN(y)) {
    return y; // IEEE 754-2008: NaN payload must be preserved
    }

    double regularMod = x % y;
    if (Double.IsNaN(regularMod)) {
    return Double.NaN;
    }
    // ...
    }

关于c# - C# (.Net) 是否区分信号 NaN 和静默 NaN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29623567/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com