0% found this document useful (0 votes)
20 views23 pages

Chapter 2

This document summarizes key concepts from Chapter 2 on number systems, operations, and codes. It discusses (1) decimal, binary, octal, and hexadecimal number systems and conversions between them, (2) common number codes like Gray code, BCD, and ASCII, and (3) representations of negative numbers using sign-magnitude, one's complement, and two's complement along with arithmetic operations on binary numbers.

Uploaded by

Izzah Amani
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)
20 views23 pages

Chapter 2

This document summarizes key concepts from Chapter 2 on number systems, operations, and codes. It discusses (1) decimal, binary, octal, and hexadecimal number systems and conversions between them, (2) common number codes like Gray code, BCD, and ASCII, and (3) representations of negative numbers using sign-magnitude, one's complement, and two's complement along with arithmetic operations on binary numbers.

Uploaded by

Izzah Amani
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/ 23

Chapter 2 : Number systems, Operation

and Codes
1. Introduction, decimal, binary, octal and hexadecimal number
systems.
2. Conversions between number systems.
3. Number codes: Gray, BCD and ASCII.
4. Representation of negative numbers: sign and magnitude, one’s
complement and two’s complement.
5. Arithmetic operations on binary numbers and two’s complement
numbers

(STB24403 Digital Electronics)


Introduction, Decimal, Binary, Octal And
Hexadecimal Number Systems
DECIMAL BINARY
Most common number system used in daily Commonly used in digital system
routine Each digit (bit) starts from 0 to 1 (Bi.. Get it?)
Each digit starts from 0 to 9
1011012
25098710

OCTAL HEXADECIMAL
A way to represent binary number Commonly used simpler way to represent binary
Each digit starts from 0 to 8 (Octa.. Get it?) number
Each digit starts from 0 to 15
2732148 10 12 13 14 15 are represented with A B C D E F

𝐵𝐴𝐵𝐸1238
(STB24403 Digital Electronics)
Conversions between number systems.
Conversion To Decimal
Binary 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎 In decimal
11101 1 × 16 + 1 × 8 + 1 × 4 + 0 × 2 + 1 × 1
16 8 4 2 1
1 1 1 0 1
29
Octal 𝟖𝟑 𝟖𝟐 𝟖𝟏 𝟖𝟎 In decimal
7205 512 64 8 1 7 × 512 + 2 × 64 + 0 × 8 + 5 × 1
7 2 0 5 3717

Hexa 𝟏𝟔𝟐 𝟏𝟔𝟏 𝟏𝟔𝟎 In decimal


AB3 256 16 1 10 × 256 + 11 × 16 + 3 × 1
A B 3 2739

(STB24403 Digital Electronics)


Conversions between number systems.
Conversion Decimal To Binary, Octal and Hexa
102 to Binary 3431 to Octal 8910 to Hexa
Divide by 2 Round Remainder Divide by 8 Round Remainder Divide by 16 Round Remainder
102/2 51 0
3431/8 428 7 8910/16 556 14 = E
51/2 25 1
25/2 12 1 428/8 53 4 556/16 34 12 = C
12/2 6 0
6/2 3 0 53/8 6 5 34/16 2 2
3/2 1 1
6/8 0 6 2/16 0 2
1/2 0 1

1100110 6547 22CE


(STB24403 Digital Electronics)
Conversions between number systems.
Conversion Binary To Octal and Hexa
1100101101 to Octal using 421 addition 11100111011 to Hexa using 8421 addition

001100101101011100111011
1 4 5 5 7 3 11=B
1455 73B

(STB24403 Digital Electronics)


Conversions between number systems.
Conversion Binary From Octal and Hexa
4621 from Octal using 421 addition F3B from Hexa using 8421 addition

4 6 2 1 F=15 3 B=11
100110010001111100111011
100110010001 111100111011

(STB24403 Digital Electronics)


Number codes: Gray, BCD and ASCII.
Gray code is a binary code that are used for precision application which
are less affected by error.
Gray code is converted from binary as below
Binary A B C D E Binary 1 1 0 1 1
Gray A A+B B+C C+D D+E Gray 1 0 1 1 0

Binary code can be obtained from Gray code as below


Gray A B C D E Gray 1 0 1 1 1
Binary A A+B A+B+C A+B+C+D A+B+C+D+E Binary 1 1 0 1 0

(STB24403 Digital Electronics)


Number codes: Gray, BCD and ASCII.
Binary coded decimal is a way of representing each decimal digit in
binary number separately by using 8421 addition
DECIMAL 7 4 9 3

BCD 0 1 1 1 0 1 0 0 1 0 0 1 0 0 1 1

(STB24403 Digital Electronics)


Number codes: Gray, BCD and ASCII.
Alphanumeric code used in most computer the code represents not
only number, but also alphabet and symbols
Every specific keyboard key have a specific ASCII code
7 bit binary code XXXXXX2 or in 8 bit form 0XXXXXX2 @ 7FH
128 Characters and symbols with ASCII code 0 to 127

(STB24403 Digital Electronics)


Number codes: Gray, BCD and ASCII.

(STB24403 Digital Electronics)


Representation Of Negative Numbers
Digital system must be able to handle both +ve and –ve no.

A signed binary number consists of sign and magnitude


information.

3 forms of signed binary number:


Sign-magnitude
1’s complement
2’s complement
(STB24403 Digital Electronics)
Representation Of Negative Numbers
Sign Magnitude

𝑿𝑿𝑿𝑿𝑿𝑿𝑿𝑿𝟐
Sign indicates if the number if +ve (0) or –ve (1)
Magnitude is the value of the number in true binary
(uncomplemented)

+𝟑𝟗𝟏𝟎 = 𝟎𝟎𝟏𝟎𝟎𝟏𝟏𝟏𝟐
−𝟑𝟗𝟏𝟎 = 𝟏𝟎𝟏𝟎𝟎𝟏𝟏𝟏𝟐
(STB24403 Digital Electronics)
Representation Of Negative Numbers
1’s Complement
+ve numbers are similar to sign-magnitude
-ve numbers are the complements/inversion of the +ve
number.

𝐗𝐗𝐗𝐗𝐗𝐗𝐗𝐗 𝟐 𝟏𝟎𝟎𝟏𝟏𝟏𝟎𝟏𝟐

𝐗𝐗𝐗𝐗𝐗𝐗𝐗𝐗 𝟐 𝟎𝟏𝟏𝟎𝟎𝟎𝟏𝟎𝟐
(STB24403 Digital Electronics)
Representation Of Negative Numbers
2’s Complement
+ve numbers are similar to sign-magnitude
-ve numbers are the complements/inversion of the +ve
number and then added with 1
Most widely used signed number
Positive number 𝐗𝐗𝐗𝐗𝐗𝐗𝐗𝐗 𝟐 𝟎𝟏𝟏𝟎𝟏𝟏𝟎𝟏𝟐
-ve in 1’s compement 𝐗𝐗𝐗𝐗𝐗𝐗𝐗𝐗 𝟐 𝟏𝟎𝟎𝟏𝟎𝟎𝟏𝟎𝟐
-ve in 2’s complement 𝐗𝐗𝐗𝐗𝐗𝐗𝐗𝐗 𝟐 + 𝟏 𝟐 𝟏𝟎𝟎𝟏𝟎𝟎𝟏𝟏𝟐
(STB24403 Digital Electronics)
Representation Of Negative Numbers
Determine the decimal value of 101100002 expressed in
sign-magnitude
101100002
Sign 𝟐𝟔 𝟐𝟓 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎
1 0 1 1 0 0 0 0

− 25 + 24 = −48

*If MSB is 0, use normal way of finding decimal


(STB24403 Digital Electronics)
Representation Of Negative Numbers
Determine the decimal value of 110011112 expressed in 1’s complement

110011112
−𝟐𝟕 𝟐𝟔 𝟐𝟓 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎
1 1 0 0 1 1 1 1

= −27 + 26 + 23 + 22 + 21 + 20
= −128 + 64 + 8 + 4 + 2 + 1
= −49 (−𝒗𝒆 𝒉𝒂𝒗𝒆 𝒕𝒐 𝒂𝒅𝒅 𝟏)
= −𝟒𝟗 + 𝟏
= −𝟒𝟖
*If MSB is 0, use normal way of finding decimal

(STB24403 Digital Electronics)


Representation Of Negative Numbers
Determine the decimal value of 110100002 expressed in 2’s
complement
110100002
−𝟐𝟕 𝟐𝟔 𝟐𝟓 𝟐𝟒 𝟐𝟑 𝟐𝟐 𝟐𝟏 𝟐𝟎
1 1 0 1 0 0 0 0

= −27 + 26 + 23 + 22 + 21 + 20
= −128 + 64 + 16
= −𝟒𝟖
*If MSB is 0, use normal way of finding decimal
(STB24403 Digital Electronics)
Representation Of Negative Numbers
Total combination of n bits = 𝟐𝒏
Range of signed number of n bit = −𝟐𝒏−𝟏 to + 𝟐𝒏−𝟏 − 𝟏
* (n-1) because MSB is the sign bit

(STB24403 Digital Electronics)


Arithmetic Operations
Binary addition
1 1 Carry = Integer (Total / 2)
Carry Sum
0 1 0 Sum = Remainder (Total /2)
0+0 0 0
1 1 1
0+1 0 1 + 1 0 0 Maximum value of each bit is 1,
1+0 0 0 1 1 0 1 1+1=2 it becomes 10
1+1 1 0 1+1+1=3 it becomes 11
1+1+1 1 1

Binary subtraction
0-0 =0
01 10 1 0
1-0 =1
Borrow 1 from higher bit = value of 2
1-1 =0 - 0 1 1 0
10 - 1 =1 0 1 0 0

(STB24403 Digital Electronics)


Arithmetic Operations
Hexa Addition
Carry exist when Total > F 1 1
(1510)
A F 7

Carry = Integer (Total / 16) + 7 5 6


Sum = Remainder (Total /2) 1 2 4 D

Hexa Substraction

E 16 *Borrow 1 from higher digit = value of 16


A F 8
- 7 5 9
3 A F

(STB24403 Digital Electronics)


Arithmetic Operations
BCD Addition
Each decimal or 8421 BCD code should be added separately
If total > 9 or generated carry out of each 4 bit, invalid and need to be add with 6
Example: 67 + 59 in BCD Code = 000100100110BCD

01 1 1 01 01 11 11 1
+ 0 1 0 1 1 0 0 1
Left BCD Invalid because > 9
Right BCD invalid because
1 11 1 0 0 0 0 0 0 generate carry
+ 0 1 1 0 0 1 1 0 Add 6 to each invalid
0 0 0 1 0 0 1 0 0 1 1 0 Valid BCD
1 2 6

(STB24403 Digital Electronics)


Arithmetic Operations
BCD ADDITION BCD ADDITION
Both numbers positive Positive magnitude larger than negative

Total is in true binary. Total is in true binary.

BCD ADDITION BCD ADDITION


Negative magnitude larger than positive Both numbers negative

Total in 2’s complement Total in 2’s complement

(STB24403 Digital Electronics)


Arithmetic Operations
SUBTRACTION
Always changed the second number to 2’s complement then changed the operation
to add.

(STB24403 Digital Electronics)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy