<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - quiet_NaN returns negative NaN"
   href="http://llvm.org/bugs/show_bug.cgi?id=16666">16666</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>quiet_NaN returns negative NaN
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Headers
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>breese@stofanet.dk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>