- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想知道如何打印 float 是 QNAN 还是 SNAN。我已经将这些位分离为 signBit exponentBit 和 FractBits。
unsigned int sign = (i & 0x80000000) >> 31;
unsigned int exponent = (i & 0x7f800000) >> 23;
unsigned int fraction = (i & 0x007FFFFF);
printf("signBit %d, expBits %d, fractBits 0x%08X\n",sign, exponent, fraction);
最佳答案
GNU provides设施 recently standardized :
Macro:
int issignaling (float-type x)
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This macro returns a nonzero value if x is a signaling NaN (sNaN). It is based on draft TS 18661 and currently enabled as a GNU extension.
最终的 TS 草案提到您可能需要选择使用宏来获取它:
#define __STDC_WANT_IEC_60559_BFP_EXT__
#include <math.h>
int issignaling(real-floating x);
关于c++ - 如何判断一个 float 是 SNAN 还是 QNAN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29666236/
运行 Tim Bailey 的《C 编程语言和软件设计简介》第 2 章中的以下代码在 Android 上的 C4Droid 中运行良好,但在 Windows 中使用带有 GCC 编译器的 CodeBl
我需要比较两个 std::list ,但有些 double 可能是无效数字 (QNAN)。如果任何无效数字是列表条目,比较过程将不起作用,因为相同无效值的比较将始终导致“假”。解决问题最简单、最优雅的
嘿,我从以下函数中得到“不是数字”的返回值: void Spider::setAngles(double x,double y, double l1, double l2){ double theta
我正在使用 C++ 绑定(bind)在 OpenCL 中编程。我有一个问题,在 NVidia 硬件上,我的 OpenCL 代码自发地产生非常大的数字,然后(在下一次运行时)一个“1.#QNaN”。我的
我想知道如何打印 float 是 QNAN 还是 SNAN。我已经将这些位分离为 signBit exponentBit 和 FractBits。 unsigned int sign = (i & 0
我注意到 Haskell(来自 Windows 上 Haskell 平台的 ghci 7.10.2)翻转了 QNAN 上的标志 (0/0 :: Double)从我在 C++ 中看到的(测试 MSVS
我已将 Visual Studio 配置为通过 _controlfp 函数抛出浮点异常。这适用于 NAN 和 INF,但不适用于 QNAN。 IE。安静的 NaN 不会引发异常。 Visual Stu
我正在用 C 编写一个简单的程序,它打印出值、内存中分配的字节数、每种数据类型的最大值和最小值。实际上,我只是在长双部分方面遇到问题。简单地说,它不会打印出我分配给 long double 变量的值,
背景: 我正在努力从 SQL Server 2000 迁移到 SQL Server 2005。这是为使用 SQL Native Client 通过 ODBC 与 SQL Server 通信的 C++
我是一名优秀的程序员,十分优秀!