0% found this document useful (0 votes)
17 views15 pages

INS3179 Digital Design Lecture 2 Numering Systems

The document discusses various numbering systems including decimal, binary, octal, and hexadecimal. It provides details on how each system works, such as the radix (base) and valid digits. Conversion between these numbering systems is also covered, with methods shown for converting from other bases to decimal and vice versa. Examples are provided to demonstrate the conversion calculations and processes.

Uploaded by

SATYAM MISHRA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views15 pages

INS3179 Digital Design Lecture 2 Numering Systems

The document discusses various numbering systems including decimal, binary, octal, and hexadecimal. It provides details on how each system works, such as the radix (base) and valid digits. Conversion between these numbering systems is also covered, with methods shown for converting from other bases to decimal and vice versa. Examples are provided to demonstrate the conversion calculations and processes.

Uploaded by

SATYAM MISHRA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

3/29/2023

VIETNAM NATIONAL UNIVERSITY HANOI (VNU)


VNU INFORMATION TECHNOLOGY INSTITUTE (VNU-ITI)

Digital Design: Numbering systems


Xuan-Tu Tran, PhD
Smart Integrated Systems (SISLAB) Group,
Vietnam National University, Hanoi
Email: [email protected]
www.uet.vnu.edu.vn/~tutx

Topics

❑ Introduction to Numbering Systems


(weighted or non-weighted number systems, decimal / binary / hexadecimal number systems,…)
❑ Converting between number systems
– Radix r-to-Decimal Conversion
– Decimal-to-Radix r Conversions
❑ Binary Arithmetic
– Complement Arithmetic
❑ Binary Signed Representation
❑ Coding
– Binary-coded Decimal (BCD)
– BCD-to-Binary and Binary-to-BCD Conversions
– Other codes for representing numbers (Gray code, 2/5 code, Johnson code,…)
– Alphanumeric Codes (ASCII, EBCDIC codes)
3/29/2023 Xuan-Tu Tran 2

1
3/29/2023

Introduction to number systems

❑ 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

❑ Weighted or Non-weighted number systems


– Non-weighted number systems:
▪ The value of a digit does not depend to its location
▪ Roman numerals (eg., XXI = 21, XXXIX = 39)
– Weighted number systems:
▪ The value of a digit depends to its location
▪ For example, decimal, binary systems

3/29/2023 Xuan-Tu Tran 3

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 + …

3/29/2023 Xuan-Tu Tran 4

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 + …

3/29/2023 Xuan-Tu Tran 5

Other number systems

❑ Octal system
– Radix = 8

– Digits: 0, 1, 2, 3, 4, 5, 6, and 7

– Example: (24)8 = 2×81 + 4×80 = (20)10

❑ Hexadecimal system
– Radix = 16

– Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F

– Example: (03F8)16 = 0×163 + 3×162 + F×161 + 8×160 = (1032)10

3/29/2023 Xuan-Tu Tran 6

3
3/29/2023

Base conversions

❑ Why do we have to do conversion between number systems?

❑ Radix r-to-Decimal conversions


– The position of each digit indicates the weight associated with the digit.

– Use the follow equation:

– (A)B = AnBn + An-1Bn-1 + An-2Bn-2 + … + A1B1 + A0B0 + A-1B-1 + …

– (276.5)10 = 2×102 + 7×101 + 6×100 + 5×10-1

– (1321)4 = 1×43 + 3×42 + 2×41 + 1×40 = 64 + 48 + 8 + 1 =12110

3/29/2023 Xuan-Tu Tran 7

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

3/29/2023 Xuan-Tu Tran 9

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:

– Continue until no integral part remains → we have all


digits of Ar

3/29/2023 Xuan-Tu Tran 10

5
3/29/2023

Base conversions

• An example
– Finding the base 3 equivalent of (278)10

dividend divisor quotient remainder


278 : 3 = 92; 2 = a0
92 : 3 = 30; 2 = a1
30 : 3 = 10; 0 = a2
10 : 3 = 3; 1 = a3
3 : 3 = 1; 0 = a4
1 : 3 = 0; 1 = a5
0 → Stop

Thus, (278)10 = (101022)3

3/29/2023 Xuan-Tu Tran 11

Base conversions

• Decimal-to-Radix r conversions (fractional part)


– Let B10 now represents a fractional decimal number equivalent to a
fractional number Ar in radix r. Thus

B10 = Ar = (0.a−1a−2  a−m )r

= 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

→The fractional part is (a −2 r −1 +  + a− m r − m +1 )


3/29/2023 Xuan-Tu Tran 12

6
3/29/2023

Base conversions

• Decimal-to-Radix r conversions (fractional part)


– Repeat the process with the fractional part

• The next integral part will be a2 (a −2 r −1 +  + a− m r − m +1 )


• The next fractional part will be (a −3 r −1 +  + a−m r − m+ 2 )
– Continue until no fractional part remains → we have all digits of Ar

3/29/2023 Xuan-Tu Tran 13

Base conversions

• An example
– The conversion of (0.27)10 = (?)4

Old fraction New fraction ai


0.27 × 4 = 1.08 0.08 a-1 = 1
0.08 × 4 = 0.32 0.32 a-2 = 0
0.32 × 4 = 1.28 0.28 a-3 = 1
0.28 × 4 = 1.12 0.12 a-4 = 1
… … … …

Thus (0.27)10 = (0.1011……)4

3/29/2023 Xuan-Tu Tran 14

7
3/29/2023

Binary-to-Decimal conversion

❑ Do the following conversions

– (10001100)2 → (?)10

– (00010111)2 → (?)10

– (1010.1100)2 → (?)10

3/29/2023 Xuan-Tu Tran 15

Decimal-to-Binary conversion

❑ Do the following conversions

– (123)10 = (?)2

– (255)10 = (?)2

– (0.125)10 = (?)2

– (12.250)10 = (?)2

3/29/2023 Xuan-Tu Tran 16

8
3/29/2023

Binary  Hexadecimal conversions

❑ Hexadecimal-to-Binary conversion

– Convert each digit to a nibble (a group of 4 bits in the Binary system)

– (12F8)16 = (0001 0010 1111 1000)2

❑ Binary-to-Hexadecimal conversion

– Group

3/29/2023 Xuan-Tu Tran 17

Binary Arithmetic

❑ Addition

❑ Multiplication

❑ Subtraction

❑ Division

3/29/2023 Xuan-Tu Tran 18

9
3/29/2023

Complement Arithmetic

❑Radix and diminished radix complements


– Radix complement
▪ Let A be an n-digit integer in radix r representation

▪ Radix complement of A is:

A* = radix complement of A = rn - A

– Diminished radix complement is defined as:


A+ = diminished radix complement of A = rn – A – 1

3/29/2023 Xuan-Tu Tran 19

Complement Arithmetic

❑Binary numbering system


– 1’s complement
▪ Interchanging 1s and 0s
▪ Example: 1001 => 0110

– 2’s complement
▪ 1’s complement + 1
▪ From the previous example: 0110 + 1 = 0111

– 2’s complement of 1001 is 0111

– 2’s complement is used in subtraction

3/29/2023 Xuan-Tu Tran 20

10
3/29/2023

Encoding: Binary-to-complement

• Binary-to-complement binary encoding


Binary code
– 2’s complement used to represent the negative
number.

– Subtraction can be done by the addition with a


1’s complement code
2’s complement number.
1110
original number 1011
inversion
2’s complement code
1’s complement 0100
+1
2’s complement 0101
-1110
3/29/2023 Xuan-Tu Tran 21

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

3/29/2023 Xuan-Tu Tran 22

11
3/29/2023

Binary Codes for Decimal (BCD) numbers

❑ Why BCD code?


– The external interfaces of a digital system may read or display decimal numbers, even
some digital devices actually process decimal numbers directly
– The human need to represent decimal number w/o changing the basic nature of digital
electronic circuits
❑ BCD codes
– Natural decimal code uses a combination of 4 bits to represent a decimal number.
▪ BCD encodes the digits 0 through 9 by their 4-bit unsigned binary representations, 0000 through
1001.
– For example,
▪ 0011BCD encodes 310
▪ 1001BCD encodes 910

3/29/2023 Xuan-Tu Tran 23

Binary Codes for Decimal (BCD) numbers

Decimal digit BCD (8421) 2421 Excess-3 Biquinary 1-out-of-10

0 0000 0000 0011 0100001 1000000000

1 0001 0001 0100 0100010 0100000000

2 0010 0010 0101 0100100 0010000000

3 0011 0011 0110 0101000 0001000000

4 0100 0100 0111 0110000 0000100000

5 0101 1011 1000 1000001 0000010000

6 0110 1100 1001 1000010 0000001000

7 0111 1101 1010 1000100 0000000100

8 1000 1110 1011 1001000 0000000010

9 1001 1111 1100 1010000 0000000001

3/29/2023 Xuan-Tu Tran 24

12
3/29/2023

Gray Code

❑ Gray code: only one change in bit between two successive numbers

❑ Why Gray code?


– Enhance the reliability of automatic systems such as machine tools, automotive braking systems,
copiers…

3/29/2023 Xuan-Tu Tran 25

Gray Code

Mechanical encoding
disk using a 3-bit binary
code

0 0 1

3/29/2023 Xuan-Tu Tran 26

13
3/29/2023

Gray Code

Mechanical encoding
disk using a 3-bit
Gray code

0 0 1

3/29/2023 Xuan-Tu Tran 27

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

VIETNAM NATIONAL UNIVERSITY HANOI (VNU)


VNU INFORMATION TECHNOLOGY INSTITUTE (VNU-ITI)

Thank you!

Xuan-Tu Tran, PhD


Smart Integrated Systems (SISLAB) Group,
Vietnam National University, Hanoi
Email: [email protected]
www.uet.vnu.edu.vn/~tutx

15

You might also like