1 /** @file z80/support.c
7 convertFloat (Z80_FLOAT * f, double native)
9 unsigned long mantissa, exponent;
14 f2 = floor (log (fabs (native)) / log (2)) + 1;
15 mantissa = (unsigned long) (0x1000000 * fabs (native) / exp (f2 * log (2))) ;
17 exponent = (unsigned long) (f2 + 0x40) ;
27 f->w[0] = (WORD) mantissa;
28 f->w[1] = (BYTE) (mantissa >> 16);
29 f->w[1] |= exponent << 8;
31 f->b[0] = (BYTE) f->w[0];
32 f->b[1] = (BYTE) (f->w[0] >> 8);
33 f->b[2] = (BYTE) f->w[1];
34 f->b[3] = (BYTE) (f->w[1] >> 8);