Professional Documents
Culture Documents
Gianluca Biccari
(Email: gb@gianlucabiccari.com)
Binary Format
fractional part
binary point
Qm.n format: m bit for whole part, n bit for fractional part.
bn+m-1 . . . bn+1 bn
bn-1
1
x [B10] = n
2
fractional part adjustment
x min =0
2 N 1 m n
x max = n = 2 2
2
resolution: 2-n
...
b2 b1 b0
N 1
2 b
i
i =0
i.e. : Q16.16
N = 32 bit
range: 0 (216 2-16 ) = 65535,99998
resolution: 3,05 10-5
10000
MSB = 1
MSB = 0
1111
1110
1101
1000
0000
0001
0010
0111
24 = 16
-1 (16-1=15)
-2 (16-2=14)
-3 (16-3=13)
-8 (16-8=8)
0
+1
+2
+7
b3 b2 b1 b0
N 2
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
1111
1110
1101
1000
0000
0001
0010
0111
-1 (=-8+7)
-2 (=-8+6)
-3 (=-8+5)
-8 (=-8+0)
0 (=0+0)
+1(=0+1)
+2(=0+2)
+7(=0+7)
N = m + n + 1 bit
fractional part
adjustment
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
bn-1
b2 b1 b0
x like twos
complement
number
i.e. : Q2.13
N = 16 bit
range: -22 (22 2-13 ) = - 4 3,99987
resolution: 1,22 10-4
Float value
Qm.n value
N 2
x [B10] 2 n = 2 N 1 bN 1 + 2i bi
i =0
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]
Example2:
0xFB0EA9BA=(1111 1011 0000 1110 1010 1001 1011 1010)[B2]
= ( -231 + (2064558522) ) / 216 = -1265.337
Resolution:
is the smallest non-zero magnitude representable, = 2-n
Accuracy:
is the magnitude of the maximum difference between a real
value and its representation, = 2-n/2 = 2-n-1