This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
floating point formats, again
- To: gcc at gcc dot gnu dot org
- Subject: floating point formats, again
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Sun, 11 Mar 2001 21:42:31 -0800
Thanks to all who helped out last time.
Once again, I'd appreciate if those with access to VAXes and IBM
mainframes, PDP/10s, and other hardware with unusual floating-point
formats could compile the appended program and report what it prints.
Exactly one line of the output should have a recognizable string in
its rightmost column; the rest should be dots and the occasional
character.
"Unusual" means "not IEEE."
Thanks.
zw
#include <stdio.h>
#include <ctype.h>
static double n[] =
{
3.25724264705901305206e+01, /* @@IEEEFP - ieee 754 */
3.53802595280598432000e+18, /* D__float - VAX */
1.10037057600060735398e-05, /* p.rstuvw - PDP10 */
1.77977764695171661377e+10, /* IBMHEXFP - s/390 format, ascii */
-5.22995989424860458374e+10 /* IBMHEXFP - s/390 format, EBCDIC */
};
#define X(n) (isgraph(x[n]) ? x[n] : '.')
int main(void)
{
int i;
if (sizeof(double) != 8)
printf("*** sizeof(double) == %d\n", sizeof(double));
for (i = 0; i < (sizeof(n) / sizeof(double)); i++)
{
unsigned char *x = (unsigned char *) (n + i);
printf("%.20e\t"
"%.2x%.2x%.2x%.2x %.2x%.2x%.2x%.2x\t"
"%c%c%c%c%c%c%c%c\n",
n[i],
x[0], x[1], x[2], x[3],
x[4], x[5], x[6], x[7],
X(0), X(1), X(2), X(3),
X(4), X(5), X(6), X(7));
}
return 0;
}