|
|
1.1 ! root 1: /* C compiler: MC68020 float/double decoding */ ! 2: ! 3: #include "c.h" ! 4: ! 5: struct real decode(ty, x) double x; { ! 6: struct real r; ! 7: ! 8: if (ty == D) { ! 9: struct d { unsigned sign:1, exp:11, fract1:20, fract2;} *p = (struct d *) &x; ! 10: r.sign = p->sign; ! 11: r.exp = x ? p->exp - 1023 : 0; ! 12: r.msb = (p->fract1<<12) | (p->fract2>>20); ! 13: r.lsb = p->fract2<<12; ! 14: } else { ! 15: float f = x; ! 16: struct f { unsigned sign:1, exp:8, fract:23; } *p = (struct f *) &f; ! 17: r.sign = p->sign; ! 18: r.exp = f ? p->exp - 127 : 0; ! 19: r.msb = p->fract<<9; ! 20: r.lsb = 0; ! 21: } ! 22: return r; ! 23: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.