* Long double print anomaly on Solaris
@ 1999-01-31 23:58 Jim McKelvey
0 siblings, 0 replies; only message in thread
From: Jim McKelvey @ 1999-01-31 23:58 UTC (permalink / raw)
To: egcs
This sample program computes and prints out the largest odd integer
that can be stored in a long double.
egcs prints:
10384593717069655257060992658440192
406fffffffffffffffffffffffffffff
The Sun CC compiler prints:
10384593717069655257060992658440191
406fffffffffffffffffffffffffffff
egcs is wrong, since the number is odd.
uname -a:
SunOS doberman.jpl.nasa.gov 5.5.1 Generic_103640-20 sun4u sparc
SUNW,Ultra-2
egcs-19990112
#include <fstream.h>
#include <iomanip.h>
union un
{
long double ld;
unsigned char c[16];
};
int main(void)
{
un ldtest;
long double temp;
ldtest.ld = 0.0L;
while (1)
{
temp = ldtest.ld + ldtest.ld + 1.0L;
if ((temp - 1.0L) == temp)
{
break;
}
ldtest.ld = temp;
}
cout << setprecision(100) << ldtest.ld << endl;
for (int i = 0; i < 16; i++)
{
cout << setfill('0') << setw(2) << setbase(16) <<
int(ldtest.c[i]);
}
cout << endl;
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-01-31 23:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-31 23:58 Long double print anomaly on Solaris Jim McKelvey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).