John T. said:
I have a number in 8.8 notation that I wish to convert to a float.......
8.8 notation is a 16 bit fixed notation, so:
0xFF11 is the number 255.17
0x0104 is the number 1.4
0x2356 is the number 35.86
and so on....
Any ideas on how to convert this into a float?
Not without a better specification of your notation.
I'd normally expect a 16-bit fixed-point notation to have the
high-order 8 bits represent the integer part and the low-order 8 bits
represent the fractional part, with 0x0001 representing 1.0/256.0,
0x00FF representing 255.0/256.0, etc. In that case, you'd simply
multiply by 256.0.
Or you could have the low-order 8 bits represent a multiple of 0.01
(decimal) rather than of 1.0/256.0; in that case, you'd have to
extract the high-order and low-order parts and do a little arithmetic.
In such a notation, though, 0x0104 would be 1.04, not 1.4; was that
just a typo? Such a notation is a bit inefficient, since you're using
8 bits to represent any of 100 values rather than 256 values. If
that's what you're dealing with, though, it's merely odd, not wrong.
Keep in mind that some fractional values, such as 0.1, cannot be
represented exactly in binary floating-point. Note also that your
format has no way of representing negative numbers.