在g ++ 4.4.3上获得一个负NaN,是这个标准吗? [英] Getting a negative NaN on g++ 4.4.3, is this standard?

查看:158
本文介绍了在g ++ 4.4.3上获得一个负NaN,是这个标准吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-nan


$ b $在Ubuntu Lucid Lynx的Linux上有g ++ 4.4.3结果是b

。在g ++ 4.3.1上,我得到了所有的



nan



这导致我的文本差异回归失败,因为我正在使用cout来打印这个数字结果。

一个有符号的nan的含义是什么,有没有办法告诉编译器:无符号的nan就足够了?

解决方案

行为的改变可能是由于库而不是编译器导致的。 glibc在glibc源代码中肯定会发生一些变化 - 从2009-08-23 2528行: ChangeLog.17 p>

  ... 
* stdio-common / printf_fp.c:ISO C期望打印NaN
以及。
...


I have g++ 4.4.3 on Linux with Ubuntu Lucid Lynx, and I am getting a:

-nan

as a result. On Hardy Heron with g++ 4.3.1, I am getting all

nan

This is causing my text diff regression to fail, since I am using cout to print this numerical result.

What is the meaning of a signed nan, and is there a way to tell the compiler that an unsigned nan is sufficient?

解决方案

The change in behaviour may be due to libraries rather than the compiler. There is certainly a change in glibc around the right sort of time - from the entry for 2009-08-23 at line 2528 in ChangeLog.17 in the glibc source:

...
     * stdio-common/printf_fp.c: ISO C expects to print the sign of NaN
     as well.
...

这篇关于在g ++ 4.4.3上获得一个负NaN,是这个标准吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆