Oops, I seemed to copy Q1.14 instead of Q14.1, but isn't it still the same. When I added some debug messages it still seemed to be corret.
Lowest number (-32768) is represented with 16th bit '1' and the rest are zeros, right? That is 0x8000. -1 has all the bits set (0xffff) and 0 has all the bit cleared (0x0000). Highest positive value has 16th bit cleared and the rest set (0x7fff).
Or did I interpret something wrong?
Cheers, Ilkka
I guess it's just fine, but let's see. Maybe I was lost in the Q1.14: m + n + 1 ~ binary: [sign bit, (m), (n)] where m is the integer portion, 0 or 1, n is 14 bits.. so if your input was [-32768... 32767] -> [-2,2] then, for example, -32768 is in hex: 0x8000, but the 2nd most significant bit is zero, which means the integer portion (m) is not 1, which makes me doubt the gain -32768 is actually -1 (or 0), not -2. But then, as it's a two's complement, it maybe just correct.
So most likely it's just fine; I just had a thinko.
- Eero