|
|
1.1 root 1: /*
2: * read or print machine-dependent data structures
3: * this version for a vax running on a vax
4: */
5:
6: #include "defs.h"
7:
8: /*
9: * read an ASCII expression
10: */
11:
12: char lastc;
13:
14: WORD
15: ascval()
16: {
17: long l;
18: register char *p;
19: register int i;
20:
21: l = 0;
22: p = (char *)&l;
23: i = sizeof(l);
24: while (quotchar()) {
25: if (--i >= 0)
26: *p++ = lastc;
27: }
28: return ((WORD)l);
29: }
30:
31: /*
32: * read a floating point number in VAX format
33: * the result must fit in a WORD
34: */
35:
36: WORD
37: fpin(buf)
38: char *buf;
39: {
40: union {
41: WORD w;
42: float f;
43: } x;
44: double atof();
45:
46: x.f = atof(buf);
47: return (x.w);
48: }
49:
50: /*
51: * print a floating point number in VAX format
52: */
53:
54: #define FPWID 32
55:
56: fpout(flag, va)
57: char flag;
58: char *va;
59: {
60: char buf[FPWID+1];
61: char *gcvt();
62:
63: if (flag == 'f')
64: printf("%-16s", gcvt((double)*(float *)va, 9, buf));
65: else
66: printf("%-32s", gcvt(*(double *)va, 18, buf));
67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.