[LLVMbugs] [Bug 15751] New: reading a long double from a stream is out by a factor of 10

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 15 09:39:02 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15751

            Bug ID: 15751
           Summary: reading a long double from a stream is out by a factor
                    of 10
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: john at johnmaddock.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This issue is causing most of the Boost.Math lib tests to fail, sample code is:

int main(int argc, char** argv)
{
   std::stringstream ss;
   long double r3;
   ss << "304888344611713860501504000000";
   ss >> r3;

   std::cout << std::setprecision(std::numeric_limits<long
double>::max_digits10) << r3 << std::endl;

   r3 = 304888344611713860501504000000.0L;
   std::cout << std::setprecision(std::numeric_limits<long
double>::max_digits10) << r3 << std::endl;

   return 0;
}

Which outputs:

3.04888344611713860494e+28
3.04888344611713860494e+29

Note how the value read from the stream is 10 times too small :-(

The issue still occurs if I append a ".0" to the input string.

Platform is Ubuntu Linux, latest clang and libc++ SVN Trunk.  Same issue with
last release as well.   GCC/libstdc++ and MSVC both handle this fine.

-- 
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/20130415/0a57eb9e/attachment.html>


More information about the llvm-bugs mailing list