8 * convert a float to an ieee single precision number v1.1
12 * bugs: doesn't handle subnormal numbers
13 * bugs: assumes length of integer >= 25 bits
16 int flt2ieee(float x
, unsigned char *ieee
) {
23 ieee
[0] = ieee
[1] = ieee
[2] = ieee
[3] = 0;
33 mant
= frexp((double) x
, &exp
);
37 umant
= mant
* 16777216 + 0.5;
38 if (umant
>= 16777216) {
42 /* bit 24 should be a 1 .. not used in ieee format */
49 ieee
[1] = ieee
[2] = ieee
[3] = 0;
56 ieee
[2] = ieee
[3] = 0;
61 ieee
[0] = sign
+ (exp
>> 1);
63 ieee
[3] = umant
& 255;
64 ieee
[2] = (umant
>> 8) & 255;
65 ieee
[1] = ((exp
& 1) << 7) + ((umant
>> 16) & 127);