Fixed Point Tutorial PDF
Fixed Point Tutorial PDF
Gianluca Biccari
(Email: [email protected])
Binary Format
N binary digits (bit) has 2N states. There is no an unique meaning inherent in a binary word, it depends on the representation and mapping choose.
Most of the time people are used to think of binary word as a positive integers but in digital signal processing real numbers are required!
binary point
Qm.n format: m bit for whole part, n bit for fractional part. Floating point representation: the position of the point must be determined at processing time. These calculations are much slower than fixed point. The reason for using floating point representation is that the range of possible values is much greater.
...
b2 b1 b0
1 x [B10] = n 2
fractional part adjustment
2 b
i i =0
x min =0 2 N 1 m n x max = n = 2 2 2
resolution: 2-n
i.e. : Q16.16 N = 32 bit range: 0 (216 2-16 ) = 65535,99998 resolution: 3,05 10-5
Example3: 0xD7
MSB = 1
MSB = 0
x [B10] = 2
N 1
bN 1 + 2 bi
i i =0
bN-1 = 1
Example: N = 4, x = 1101 x[B2] = 1101 x[B10] = -8+5 = -3 x[B2] = 0101 x[B10] = 0+3 = 3
bN-1 = 0
N = m + n + 1 bit
bn-1 ... b2 b1 b0
x [B10]
N 2 1 = n 2 N 1 bN 1 + 2i bi 2 i =0
2 N 1 x min = n = 2 m 2
2 N 1 1 m n x max = =2 2 n 2
resolution: 2-n
i.e. : Q2.13 N = 16 bit range: -22 (22 2-13 ) = - 4 3,99987 resolution: 1,22 10-4
Float value
From float to Qm.m:
Qm.n value
[
N 2
x [B10] 2 n = 2 N 1 bN 1 + 2i bi
i =0
Qm.n is the 2s complement representation of the float value multiplied by 2n. Examples: Q4.4 N=9, resolution= 0.0625, range: -16 15,9375 9.6 9.6 24 =153.6 = (round) 154 = (0 1001 1010)[B2] -12,4 -12.4 24 = -198.4 = (round) -198 C2(198) = 29 -198 = 314 = (1 0011 1010)[B2]