santosh nath
08-20-2003, 09:56 PM
Jim Thomas <[email protected]> wrote in message news:<[email protected]>...
> News wrote:
>
> > my question is why need to multiply by 32768, and what's the Q15 format?
>
> Ah... they are related. Q15 is a way of representing numbers between a
> little less than 1.0 and -1.0 with 16 bits. It is also called "1.15".
> The ms bit is the sign bit. The binary point (akin to the decimal
> point, but since the number is in binary rather than decimal, we can't
> call it a decimal point) follows the sign bit. The remaining bits are
> weighted by 2^(n-15), where n is the bit number (the ls bit being bit
> 0).
>
> The easiset way to convert a number to Q15 is by multiplying it by
> 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 *
> 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and
> 2^(14-15) = 2^(-1) = 0.5 which is where we started.
If the "number" is a fractional number (as you also show in an
example) then what you say is correct and represents Q15 format. It
would be nice if you
highlight how to convert a floating point number to a Q format.
For example, 7.1345, 18.6789, 154.3565 are three floating point
numbers representing samples of a signal how to convert them in Q9 and
what is the percentage reduction in precision (relative error) for
each of them?
Regards,
Santosh
> News wrote:
>
> > my question is why need to multiply by 32768, and what's the Q15 format?
>
> Ah... they are related. Q15 is a way of representing numbers between a
> little less than 1.0 and -1.0 with 16 bits. It is also called "1.15".
> The ms bit is the sign bit. The binary point (akin to the decimal
> point, but since the number is in binary rather than decimal, we can't
> call it a decimal point) follows the sign bit. The remaining bits are
> weighted by 2^(n-15), where n is the bit number (the ls bit being bit
> 0).
>
> The easiset way to convert a number to Q15 is by multiplying it by
> 32768. So to get 0.5 in Q15, we multiply it by 32768 (0x8000): 0.5 *
> 0x8000 = 0x4000. Note that the only bit equal to 1 here is bit14, and
> 2^(14-15) = 2^(-1) = 0.5 which is where we started.
If the "number" is a fractional number (as you also show in an
example) then what you say is correct and represents Q15 format. It
would be nice if you
highlight how to convert a floating point number to a Q format.
For example, 7.1345, 18.6789, 154.3565 are three floating point
numbers representing samples of a signal how to convert them in Q9 and
what is the percentage reduction in precision (relative error) for
each of them?
Regards,
Santosh