On Tue, Apr 15, 2008 at 2:30 PM, Martin Sebor <[EMAIL PROTECTED]> wrote:
> > > Farid Zaripov (JIRA) wrote: > > > > > > > [Sun C++ 5.9] 0.char test failed due to different binary > representation of "long double ld1 = 0" and "long double ld2 = 0." > > > > > > > > > > > > > > This feels like compiler bug, wouldn't you say? > > > > > > > I don't know. The both long doubles behaves as zero. The only comparing > them with memcmp() gives the wrong result. > > > > I thought there was just one bit pattern for a positive floating > point 0 in IEE 754, namely all bits clear. > > Martin // testlongdouble.cc // #include <iostream> #include <cstdlib> using namespace std; #include <stdlib.h> int main(int argc, char* argv[]) { long double x; long double y; x = static_cast<long double>(drand48()); y = static_cast<long double>(drand48()); std::cerr << "x = " << x << " y = " << y << endl; std::cerr << "sizeof(x) = " << sizeof(x) << " sizeof(y) = " << sizeof(y) << endl; std::cerr << "sizeof(x) == sizeof(y): " << ((sizeof(x) == sizeof(y)) ? "TRUE" : "FALSE") << endl; x = 0; y = 0.; std::cerr << "x = " << x << " y = " << y << endl; std::cerr << "sizeof(x) = " << sizeof(x) << " sizeof(y) = " << sizeof(y) << endl; std::cerr << "sizeof(x) == sizeof(y): " << ((sizeof(x) == sizeof(y)) ? "TRUE" : "FALSE") << endl; return 0; } // >> CC -V CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25 >> ./testlongdouble x = 0.396465 y = 0.840485 sizeof(x) = 12 sizeof(y) = 12 sizeof(x) == sizeof(y): TRUE x = 0 y = 0 sizeof(x) = 12 sizeof(y) = 12 sizeof(x) == sizeof(y): TRUE http://developers.sun.com/sunstudio/downloads/patches/ss12_patches.jsp There are more recent patches than my own installation. --Stefan -- Stefan Teleman KDE e.V. [EMAIL PROTECTED]