There are several forms of floating point representation out there. This page is not endeavouring to catalogue every floating point storage format, but those which are relevant to the architectures spoken of in other sections of this website—mostly relating to Intel 64, VAX, and PDP-11 architectures.
The following table is a summary of various floating point representations on several different platforms:
| Type | Representation of 1.0 |
|---|---|
| IEEE 754 128-bit | X'00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 3F' |
| Intel 80-bit | X'00 00 00 00 00 00 00 80 FF 3F' |
| IEEE 754 64-bit | X'00 00 00 00 00 00 F0 3F' |
| IEEE 754 32-bit | X'00 00 80 3F' |
| VAX G-float | X'10 40 00 00 00 00 00 00' |
| VAX D-float | X'80 40 00 00 00 00 00 00' |
| VAX F-float | X'80 40 00 00' |
frep ProgramThe following is a listing the frep program, which was used to
obtain the representations in the table in the previous section.
/* frep.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[]) {
char buf[BUFSIZ];
#ifndef __vax__
__float128 q;
__float80 e;
#endif
double d;
float f;
int i;
fprintf(stdout, "FREP is running on a ");
#ifdef __vax__
fprintf(stdout, "VAX");
#else
fprintf(stdout, "Intel 64");
#endif
fprintf(stdout, " system.\n");
#ifndef __vax__
q = 1.0;
e = 1.0;
#endif
d = 1.0;
f = 1.0;
#ifndef __vax__
memset(buf, 0, BUFSIZ);
memcpy(buf, &q, sizeof(q));
fprintf(stdout, "REAL*16:");
for (i = 0; i < sizeof(q); ++i)
fprintf(stdout, " %02X", buf[i] & 255);
fprintf(stdout, "\n");
memset(buf, 0, BUFSIZ);
memcpy(buf, &e, sizeof(e));
fprintf(stdout, "REAL*10:");
for (i = 0; i < sizeof(e); ++i)
fprintf(stdout, " %02X", buf[i] & 255);
fprintf(stdout, "\n");
#endif
memset(buf, 0, BUFSIZ);
memcpy(buf, &d, sizeof(d));
fprintf(stdout, " REAL*8:");
for (i = 0; i < sizeof(d); ++i)
fprintf(stdout, " %02X", buf[i] & 255);
fprintf(stdout, "\n");
memset(buf, 0, BUFSIZ);
memcpy(buf, &f, sizeof(f));
fprintf(stdout, " REAL*4:");
for (i = 0; i < sizeof(f); ++i)
fprintf(stdout, " %02X", buf[i] & 255);
fprintf(stdout, "\n");
exit(EXIT_SUCCESS);
}
Note, that on VAX, to use the G-floating point format, you must compile with
the -mg flag.
Fave icon Database CMYK © 2008 – Barry Mieny
Syntax highlighting using highlight.js by © 2006 – Ivan Sagalaev