bravoegg
Member level 2
I planned to use 8 bits to represent a sine wave in 2's complement form. Ideally it uses 1bit as sign bit, 7 bit as fractional bit, which mean I scale the sine wave by 2^7 = 128.
But when sine wave equals positive 1, it'll cause overflow after scaling. Because 1*128 exceeds the range 8bit 2's complement can represent.
I could use instead 6 bits to scale the sine wave(Q2,6), but this would reduce the precision.
I do see some people scale by (2^n - 1), and in this case it'll be scaled by 2^7-1 = 127.
Scaled by 2^7 equals shifting the binary point right by 7. But scaled by 2^7 - 1 seems to violate that relation.
Questions:
1. is it true that after scaled by (2^n - 1), I no longer know the location of binary point?
2. following (1), since I lose track of binary point, I have to treat the numbers now as INTEGERS, how can I do addition without knowledge of binary point's location?
3. what modifications needed if I still want to use 2^n, in this case, n = 7(total bit width 8) which is not enough to represent whole range.
Thanks in advance.
Sy.
But when sine wave equals positive 1, it'll cause overflow after scaling. Because 1*128 exceeds the range 8bit 2's complement can represent.
I could use instead 6 bits to scale the sine wave(Q2,6), but this would reduce the precision.
I do see some people scale by (2^n - 1), and in this case it'll be scaled by 2^7-1 = 127.
Scaled by 2^7 equals shifting the binary point right by 7. But scaled by 2^7 - 1 seems to violate that relation.
Questions:
1. is it true that after scaled by (2^n - 1), I no longer know the location of binary point?
2. following (1), since I lose track of binary point, I have to treat the numbers now as INTEGERS, how can I do addition without knowledge of binary point's location?
3. what modifications needed if I still want to use 2^n, in this case, n = 7(total bit width 8) which is not enough to represent whole range.
Thanks in advance.
Sy.