[LLVMbugs] [Bug 16666] New: quiet_NaN returns negative NaN
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jul 20 03:35:04 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16666
Bug ID: 16666
Summary: quiet_NaN returns negative NaN
Product: clang
Version: 3.2
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Headers
Assignee: unassignedclangbugs at nondot.org
Reporter: breese at stofanet.dk
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
std::numeric_limits<T>::quiet_NaN() sets the sign bit on the NaN value for
float and double. I expect it to clear the sign bit.
This sign bit can cause incompatibility problems for serialization of IEEE 754
floating-point numbers to binary streams (e.g. for network protocols.) I
currently use std::abs(std::numeric_limits<T>::quiet_NaN()) as a workaround.
The following program demostrates the problem (I have verified that the problem
is not in std::cout). The same program produces the correct results when
compiled with g++.
#include <limits>
#include <iostream>
int main()
{
std::cout << std::numeric_limits<float>::quiet_NaN() << std::endl;
std::cout << std::numeric_limits<double>::quiet_NaN() << std::endl;
return 0;
}
PS: This bug is related to 15054, which also shows the incorrectly set sign bit
in its output.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130720/27bc3b92/attachment.html>
More information about the llvm-bugs
mailing list