INS3179 Digital Design Lecture 2 Numering Systems
INS3179 Digital Design Lecture 2 Numering Systems
Topics
1
3/29/2023
❑ Number systems
– Used to represent measured values
– Composed of “Digits”
– Radix of a number system = the number of digits used in this number system
– The most often used number system: decimal system
Decimal system
❑ History
– From human habit
– Well-known
– Having a fully-constituted mathematics system
❑ Radix = 10
❑ Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
❑ Representation
– (1234)10 = 1×103 + 2×102 + 3×101 + 4×100
– (324)10 = 3×102 + 2×101 + 4×100
– (A)B = AnBn + An-1Bn-1 + An-2Bn-2 + … + A1B1 + A0B0 + A-1B-1 + …
2
3/29/2023
Binary system
❑ History
– Digital circuits are usually two state devices
(eg., relays, transistors…)
– Boolean algebraic OFF ON
– Binary system with Computer
❑ Radix = 2
❑ Digits: 0 and 1
L H ON
OFF
❑ Representation
– (1001)2 = 1×23 + 0×22 + 0×21 + 1×20 = (9)10
– (1010)2 = 1×23 + 0×22 + 1×21 + 0×20 = (10)10 n Transistors
– (A)B = AnBn + An-1Bn-1 + An-2Bn-2 + … + A1B1 + A0B0 + A-1B-1 + …
❑ Octal system
– Radix = 8
– Digits: 0, 1, 2, 3, 4, 5, 6, and 7
❑ Hexadecimal system
– Radix = 16
– Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F
3
3/29/2023
Base conversions
Base conversions
• Decimal-to-Radix r conversions
– B10 : given decimal number will be converted to Ar, radix r
B10 = Ar = (an an −1 a0 ) r
or, expanding Ar,
B10 = an r n + an −1r n −1 + + a1r 1 + a0
if B10 is divided by r, we have
B10 a
= (an r n −1 + + a2 r + a1 ) + 0
r r
B B
= Int 10 + Frac 10
r r
Int and Frac indicate the integral and fractional parts of B 10 / r
3/29/2023 Xuan-Tu Tran 8
4
3/29/2023
Base conversions
• Decimal-to-Radix r conversions
B10 a
= (an r n −1 + + a2 r + a1 ) + 0
r r
B B
= Int 10 + Frac 10
r r
From the above equation, we see that
B
a0 = Rem 10
r
Rem means the remainder of B10 / r
Base conversions
• Decimal-to-Radix r conversions
– Repeat the process with Int(B10/r) → an r n − 2 + an −1r n −3 + + a2
• The next remainder will be: a1
• The next integral part will be:
5
3/29/2023
Base conversions
• An example
– Finding the base 3 equivalent of (278)10
Base conversions
= a−1r −1 + a− 2 r −2 + + a− m r − m
Multiplying the result by r yields
(
rB10 = a−1 + a−2 r −1 + + a−m r − m +1 )
→The integral part becomes a-1
6
3/29/2023
Base conversions
Base conversions
• An example
– The conversion of (0.27)10 = (?)4
7
3/29/2023
Binary-to-Decimal conversion
– (10001100)2 → (?)10
– (00010111)2 → (?)10
– (1010.1100)2 → (?)10
Decimal-to-Binary conversion
– (123)10 = (?)2
– (255)10 = (?)2
– (0.125)10 = (?)2
– (12.250)10 = (?)2
8
3/29/2023
❑ Hexadecimal-to-Binary conversion
❑ Binary-to-Hexadecimal conversion
– Group
Binary Arithmetic
❑ Addition
❑ Multiplication
❑ Subtraction
❑ Division
9
3/29/2023
Complement Arithmetic
A* = radix complement of A = rn - A
Complement Arithmetic
– 2’s complement
▪ 1’s complement + 1
▪ From the previous example: 0110 + 1 = 0111
10
3/29/2023
Encoding: Binary-to-complement
Encoding: Binary-to-complement
Decimal Binary 2’s complement
A3 A2 A1 A0 B3 B2 B1 B0
• Binary-to-complement 0 0 0 0 0 0 0 0 0
binary encoding 1 0 0 0 1 1 1 1 1
2 0 0 1 0 1 1 1 0
3 0 0 1 1 1 1 0 1
4 0 1 0 0 1 1 0 0
B0 = A0
5 0 1 0 1 1 0 1 1
6 0 1 1 0 1 0 1 0
B1 = A0 A1 7
8
0
1
1
0
1
0
1
0
1
1
0
0
0
0
1
0
B2 = ( A0 + A1 ) A2 10
9 1
1
0
0
0
1
1
0
0
0
1
1
1
1
1
0
B3 = ( A0 + A1 + A2 ) A3 11
12
1
1
0
1
1
0
1
0
0
0
1
1
0
0
1
0
13 1 1 0 1 0 0 1 1
14 1 1 1 0 0 0 1 0
15 1 1 1 1 0 0 0 1
11
3/29/2023
12
3/29/2023
Gray Code
❑ Gray code: only one change in bit between two successive numbers
Gray Code
Mechanical encoding
disk using a 3-bit binary
code
0 0 1
13
3/29/2023
Gray Code
Mechanical encoding
disk using a 3-bit
Gray code
0 0 1
Encoding: Binary-to-Gray
Decimal Binary Gray code
A3 A2 A1 A0 G3 G2 G1 G0
• Binary-to-Gray encoding 0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
– How to encode 2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 1 0
G0 = A0 A1 4 0 1 0 0 0 1 1 0
G1 = A1 A2
5 0 1 0 1 0 1 1 1
6 0 1 1 0 0 1 0 1
G2 = A2 A3 7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
G3 = A3 9 1 0 0 1 1 1 0 1
10 1 0 1 0 1 1 1 1
11 1 0 1 1 1 1 1 0
Hint: Go from left to right, if 12 1 1 0 0 1 0 1 0
meet ‘1’ then the following bit 13 1 1 0 1 1 0 1 1
14 1 1 1 0 1 0 0 1
will be inversed.
15 1 1 1 1 1 0 0 0
3/29/2023 Xuan-Tu Tran 28
14
3/29/2023
Thank you!
15