1 /** @file z80/support.c
6 int convertFloat(Z80_FLOAT *f, double native)
8 unsigned long mantissa, exponent;
12 f2 = floor(log(fabs(native))/log(2))+1;
13 mantissa = 0x1000000*fabs(native)/exp(f2*log(2));
24 f->w[0] = (WORD)mantissa;
25 f->w[1] = (BYTE)(mantissa>>16);
26 f->w[1] |= exponent << 8;
28 f->b[0] = (BYTE)f->w[0];
29 f->b[1] = (BYTE)(f->w[0]>>8);
30 f->b[2] = (BYTE)f->w[1];
31 f->b[3] = (BYTE)(f->w[1]>>8);