SlideShare a Scribd company logo
1 of 81
Download to read offline
1
Chapter 2
Number Systems
i. Decimal, Binary, Hexadecimal, Octal
ii. Number conversions
iii. Binary Arithmetic
2
Digital Number Systems
• Many number systems are used in digital
electronics.
– Decimal number system
– Binary number system
– Octal number system
– Hexadecimal number system
3
Decimal System
• We use decimal numbers everyday
• Base-10 system
• 10 symbols: 0,1,2,3,4,5,6,7,8,9
• Examples: 23, 5, 7, 88.9, 0.2
4
Decimal System
• The position of each digit in a decimal
number can be assigned a weight
• For example: 2745.214
– 2745.214 is a decimal number
– 2 is a digit, 7 is a digit, 4 is a digit…
2 7 4 5 2 1 4.
103 102 101 100 10-110-210-3
weights
5
Decimal System
2745.21410 =
(2x103) + (7x102) + (4x101) + (5x100) + (2x10-1) + (1x10-2)
+ (4x10-3)
2 7 4 5 2 1 4.
103 102 101 100 10-110-210-3
weights
6
Decimal System
• Most significant digit (MSD)—the digit that
carries the most weight
• Least significant digit (LSD)– the digit that
carries the least weight
2 7 4 5 2 1 4.
103 102 101 100 10-110-210-3
weights
7
Decimal Counting
• 0 1 2 3 4 5 6 7 8 9-----
10 11---------------------------- 19---- 20----
------------------------------- 99---- 100------------
------
8
Binary System
• Difficult to design a system that works with
10 different voltage levels
• Base-2 system
• 2 digits/symbols: 0, 1
• Examples: 0, 1, 01, 111, 101010
• Similar to decimal number, the position of
each digit in a binary number can be
assigned a weight.
9
Binary System
• The position of each digit (bit) in a binary
number can be assigned a weight
• For example: 1011.101
– 1011.101 is a binary number
– 1 is a digit, 0 is a digit, 1 is a digit…
1 0 1 1 1 0 1.
23 22 21 20 2-1 2-2 2-3
weights
10
Binary System
1011.1012=(1x23) + (0x22) + (1x21) + (1x20) +
(1x2-1) + (0x2-2) + (1x2-3)
= 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125
= 11.62510
1 0 1 1 1 0 1.
23 22 21 20 2-1 2-2 2-3
weights
11
Binary counting
• 0 1 10 11 100 101 110 111--------
--------- 11111
12
Hexadecimal System
• Base-16 system
• 16 symbols: 10 numeric digits and 6
alphabetic characters
– 0,1,2,3,4,5,6,7,8,9
– A,B,C,D,E,F
• Compact way of writing binary number
• Widely used in computer and
microprocessor applications
13
Hexadecimal System
• Examples: 1C16 , A8516
• 1CH, A85H
• The position of each digit in a hexadecimal
number can be assigned a weight
• For example: 2AF8.98E
– 2AF8.98E is a hexadecimal number
– 2 is a digit, A is a digit, F is a digit…
2 A F 8 9 8 E.
163 162 161 160 16-116-216-3
weights
14
Hexadecimal Counting
• 0 1 2 3 4 5 6 7 8 9 A B C
D E F 10 11 12-------------------
19 1A---------------------------------------
FF 100 101 102------------------
15
Octal System
• Base-8 system
• 8 digits: 0,1,2,3,4,5,6,7
• Convenient way to express binary numbers
and codes. Use 3 bits of binary
16
Table of Number Systems
DECIMAL BINARY HEXADECIMAL OCTAL
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 8 10
9 1001 9 11
10 1010 A 12
11 1011 B 13
12 1100 C 14
13 1101 D 15
14 1110 E 16
15 1111 F 17
17
Review
• Give the largest decimal number that can be
represented in binary with 8 bits.
• Determine the weight of the 1 in 100002.
• Convert the binary number 10111101.0112 to
decimal. Ans:189.37510
18
Conversions
• Binary Decimal
• Decimal Binary
• Hexadecimal Decimal
• Decimal Hexadecimal
• Binary Hexadecimal
• Hexadecimal Binary
• Octal Decimal
• Decimal Octal
• Binary Octal
• Octal Binary
19
BINARY number DECIMAL number
Method 1: Sum-of-Weights
Binary
Decimal
Given 110012
S1: write the weights
1 1 0 0 1Binary number
weights 2021
222324
S2: write the sum of the products of each
digit with its weight
110012 =(1x24)+(1x23)+(0x22)+(0x21)+(1x20)
=16 + 8 + 1
=2510
Binary
Decimal
?
Answer: 2510
20
Decimal Binary Conversion
• Decimal number binary number
– Method: sum-of-weights
• Decimal whole number binary number
– Method: division-by-2
• Decimal fraction binary number
– Method: multiplication-by-2
21
DECIMAL number BINARY number
Method 1: Sum-of-Weights
Decimal
Binary
Given 2510
Step 1: Find the power of two that fulfills the following:
a. nearest to the given decimal number; and
b. its decimal number is less than or equal to the given decimal number.
22? No, because it is not the nearest. 8 (23) is nearer and still less than 25.
25? No, because its decimal number, 32 is more than 25.
24? Yes, because it is the nearest and its decimal, 16 is less than 25.
Step 2: Subtract the power of two (from Step 1) from the given decimal number.
25-16=9
The result of the subtraction is 9.
Step 3: If the result of the subtraction in Step 2 is 0, go to Step 4. Else, repeat Steps
1 and 2 for the result of the subtraction in Step 2.
Step 4: Write out the binary number based on all the powers of two from Step 1.
22
DECIMAL Number BINARY Number
Method 1: Sum-of-Weights
Given 5110
• Step 1: the power of two which is nearest to 51 but less than
51 is 25
• Step 2: the result of subtraction 51-32=19
• Step 3:
– Repeat Step 1: the power of two nearest to 19 but less than 19 is 24
– Repeat Step 2: the result of subtraction 19-16=3
– Repeat Step 1: the power of two which is nearest to 3 and less than 3 is 21
– Repeat Step 2: the result of subtraction 3-2=1
– Repeat Step 1: the power of two which is nearest to 1 and equal to 1is 20
– Repeat Step 2: the result of subtraction 1-1=0
• Step 4:
1 0 0 1 1Binary number
Weights 24 23 22
21 20
1
25
23
DECIMAL Number BINARY Number
Method 2: Repeated Division-by-2
• Method 1 can convert both
whole numbers and
fractional numbers to binary.
• Method 2 is to convert
whole numbers to binary.
• Given 4510
– Repeat the division until the
quotient is 0.
22
2
45
=
Remainder
11
2
22
=
5
2
11
=
2
2
5
=
1
2
2
=
0
2
1
=
Quotient
1
0
1
1
0
1
LSB
MSB
The binary number is 1011012
24
DECIMAL fraction BINARY fraction
Method 3: Repeated Multiplication-by-2
• Method 3 is to convert decimal fraction to
binary.
• Repeat the multiplication until the fractional
part is all zeros.
• Given 0.3125
0.3125 x 2 = 0.625
0.625 x 2 = 1.25
0.25 x 2 = 0.50
0.50 x 2 = 1.00
Carry
0
1
0
1
MSB
LSB
The binary fraction is
.0101
25
DECIMAL Number HEXADECIMAL Number
Method: Repeated division-by-16
• Repeat the division until the quotient is 0.
• Example: 65010
40
16
650
=
2
16
40
=
0
16
2
=
quotient Remainder
(decimal)
Remainder
(hexadecimal)
LSD
MSD
A
8
2
10
8
2
So, the hexadecimal number is 28A16
26
BINARY Number HEXADECIMAL Number
• Step 1: Break the binary number into 4-bit
groups, starting from LSB.
• Step 2: Replace each 4-bit with the equivalent
hexadecimal number.
• Example: 111111000101101001
00111111000101101001binary
hexadecimal 961F3
The hexadecimal number is 3F16916
27
HEXADECIMAL Number BINARY Number
• Step: Replace each digit of the hexadecimal
number with the equivalent 4-bit binary
number.
• Example: CF8E16
C F 8 EHexadecimal
Binary 1110100011111100
The binary number is 11001111100011102
28
DECIMAL Number OCTAL Number
Method: Repeated division-by-8
• Repeat the division until the quotient is 0.
• Example: 35910
44
8
359
=
5
8
44
=
0
8
5
=
quotient Remainder
LSD
MSD
7
4
5
So, the octal number is 5 4 78
29
BINARY Number OCTAL Number
• Step 1: Break the binary number into 3-bit
groups, starting from LSD.
• Step 2: Replace each 3-bit group with the
equivalent octal number.
• Example: 1101012
110101binary
octal 56
The octal number is 658
30
OCTAL Number BINARY Number
• Step: Replace each octal digit with the
equivalent 3-bit group.
• Example: 138
Octal
Binary
1 3
001 011
So, the binary number is 0010112
31
Exercise
• Fill in the blanks.
Decimal Binary Hexadecimal Octal
1101.0112
10101.112
245.62510
70310
A8516
32
Exercise
• Answers
Decimal Binary Hexadecimal Octal
13.37510 1101.0112 D.616 15.38
21.7510 10101.112 15.C16 25.68
245.62510 11110101.1012 F5.A16 365.58
70310 10101111112 2BF16 12778
269310 1010100001012 A8516 52058
Binary Arithmetic
• Binary addition
• Binary subtraction
• Binary multiplication
• Binary division
Binary addition
• 0 + 0 = 0 with a carry of 0
• 0 + 1 = 1 with a carry of 0
• 1 + 0 = 1 with a carry of 0
• 1 + 1 = 10 with a carry of 1
• Example: 111 + 11 = ?
111 7
+ 11 +3
1010 10
In decimal…
Binary subtraction
• 0 – 0 = 0
• 1 – 1 = 0
• 1 – 0 = 1
• 10 – 1 = 1
• Example: 101 – 11 = ?
101 5
- 11 -3
10 2
In decimal
Binary Multiplication
• 0 x 0 = 0
• 0 x 1 = 0
• 1 x 0 = 0
• 1 x 1 = 1
• Example: 101 x 111 = ?
101 5
x 111 x7
101 35
101
101
100011
Binary Division
• The procedure is same as decimal division
• Examples: 110 ÷ 11 =?
110
11
0
0
11
10
6
6
0
3
2
In decimal…
Review
• Why binary numbers? Why not decimal?
– Digital system understand binary numbers, not
decimal numbers.
Review
• Why hexadecimal?
– Shorthand of binary numbers
– Easy to convert to and from binary
• Examples:
– 1 1111 1000 0000 1010 1000 00012
– 1F80A8116
40
Chapter 2
Number Systems
iv. Binary Codes
v. Representation of Negative Numbers
vi. Arithmetic operations
41
Chapter 2
Number Systems
iv. Binary Codes
v. Representation of Negative Numbers
vi. Arithmetic operations
Outline
• Binary Codes
– BCD 8421
– Gray
– ASCII
– EBCDIC
Code and Encoding
• Code-- Special group of symbols that is used
to represent numbers, letters or words.
• Encoding– The process of converting a
number/letter/word into a code.
Number,
Letter,
Word
encoding Code
Generally,
For example,
Numbers,
Letters,
Words
Straight binary coding
Binary
number
Other Codes
• External world is decimal but digital systems
use binary numbers.
– So, conversions are often.
• Other codes are introduced because the
conversion between the code and the decimal
number is easier.
BCD Code
• Binary Coded Decimal Code
• Binary Coded Decimal (BCD)—a way to
represent each digit of a decimal number with
its 4-bit binary number.
Example: 87410
8 7 4Decimal
BCD 1000 0111 0100
Therefore, the BCD code for 87410 is 1000 0111 0100
Do you know why?
1000 1111 is not a BCD
BCD Code / 8421 Code
• Convert a BCD code to its decimal equivalent.
– Step 1: Break the BCD into 4-bit groups, starting
from LSB
– Step 2: Replace each 4-bit group with its
equivalent decimal
• Example: 0110 1000 0011 1001
6 8 3 9
So, the decimal equivalent is 683910
BCD coding vs. straight binary coding
• BCD coding is easier.
Decimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
BCD coding
13710
13710
1 3 7decimal
BCD 0001 0011 0111
The BCD code is 0001 0011 0111
137
2
68
2
=68 1
=34 0
34
2
=17 0
=8 117
2
8
2
=4 0
4
2
=2 0
2
2
=1 0
1
2
=0 1
The straight binary code is 100010012
Gray Code
• No weights assigned to
the bit positions
• Only a single bit change
from one code word to
the next in sequence.
• Good— minimize the
chance for error.
DECIMAL BINARY GRAY CODE
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Conversions
BINARY TO GRAY CONVERSION
1---+--->1 ---+--->0---+--->1---+--->1
1 0 1 1 0
GRAY TO BINARY CONVERSION
1 1 0 1 1
1 0 0 1 0
Binary
Gray
Gray
Binary
Alphanumeric codes
• Codes that represent numbers and alphabetic
characters (letters).
• At minimum, the code must represent 10
decimal digits (0-9) and 26 letters (A-Z).
• 6 bits are needed in the code that represent
the numbers and letters.
• ASCII is the most common alphanumeric code.
ASCII Code
• American Standard Code for International
Interchange
• Used in computers and electronic equipment
processor
1011001
ASCII Code
• ASCII code has 128 characters and symbols
• Represented by 7-bit binary code
• Can be considered an 8-bit code with MSB 0.
• The first 32 ASCII characters are non-graphic
commands only for control purposes—The
ASCII Control Characters.
• E.g.: null, line feed, start of text, escape
ASCII CODE
Character or
Number
ASCII-8 Binary EBCDIC Binary
A 01000001 11000001
E 01000101 11000101
Z 01011010 11101001
0 00110000 11110000
1 00110001 11110001
5 00110101 11110101
EBCDIC ALPHANUMERIC CODE
Extended Binary Coded Decimal Interchange Code
•8-bit character encoding
EBCDIC
56
Chapter 2
Number Systems
iii. Binary Codes
iv. Representation of Negative Numbers
v. Arithmetic operations
Outline
• Representation of negative numbers
– Sign and magnitude
– 1’s complement
– 2’s complement
Representation of negative numbers
• Computer must handle both positive and
negative numbers.
• A signed binary number consists of both sign
and magnitude information.
• 3 types of representation:
– Sign and magnitude (least used)
– 1’s complement
– 2’s complement (most important)
Sign and Magnitude
• The sign bit—the left-most bit in a signed
binary number
– A ‘0’ sign bit indicates a positive number
– A ‘1’ sign bit indicates a negative number
• The remaining bits are the magnitude bits.
• Example: Express the decimal number -39 as
an 8-bit number in the sign-magnitude.
3910=1001112= 0010 01112
The sign bit is 1. Therefore, -3910= 1010 01112
Sign and Magnitude
0000
0111
0011
1011
1111
1110
1101
1100
1010
1001
1000
0110
0101
0100
0010
0001
+0
+1
+2
+3
+4
+5
+6
+7-0
-1
-2
-3
-4
-5
-6
-7
0 100 = + 4
1 100 = - 4
+
-
1’s complement
• To find the 1’s complement of a given binary
number,
– Change all 1s to 0s and all 0s to 1s.
• Example: Find the 1’s complement of
10110010
1 0 1 1 0 0 1 0
0 1 0 0 1 1 0 1
1’s Complement
0000
0111
0011
1011
1111
1110
1101
1100
1010
1001
1000
0110
0101
0100
0010
0001
+0
+1
+2
+3
+4
+5
+6
+7-7
-6
-5
-4
-3
-2
-1
-0
0 100 = + 4
1 011 = - 4
+
-
2’s complement
• To find the 2’s complement of a given binary number,
– Add 1 to the LSB of the 1’s complement
• Example: Find the 2’s complement of 10110010
A 10110010 Binary number
01001101 1’s complement
+ 1 add 1
01001110 2’s complement
B 10110010
01001110
2’s Complement
0000
0111
0011
1011
1111
1110
1101
1100
1010
1001
1000
0110
0101
0100
0010
0001
+0
+1
+2
+3
+4
+5
+6
+7-8
-7
-6
-5
-4
-3
-2
-1
0 100 = + 4
1 100 = - 4
+
-
• Only one representation for 0
• One more negative number than positive number
Comparison
+19 -19
Sign-magnitude
1’s complement
2’s complement
Exercise:
Express the decimal numbers +19 and -19 as an 8-bit
number in the sign-magnitude, 1’s complement and 2’s
complement forms.
Comparison
+19 -19
Sign-magnitude 00010011 10010011
1’s complement 00010011 11101100
2’s complement 00010011 11101101
Exercise:
Express the decimal numbers +19 and -19 as an 8-bit
number in the sign-magnitude, 1’s complement and 2’s
complement forms.
Comparison
Decimal Value of Sign-Magnitude Number
• Convert the magnitude bits to its decimal
value.
• The sign bit determines whether the number
is positive or negative.
• Example: 100101012
00101012 = 24 + 22 + 20
= 16 + 4 + 1
= 21
The sign bit is 1. Therefore, the decimal number is -21.
Decimal Value of 1’s Complement Number
• Positive number:
– Sum the weights of all bit position where there are 1s.
• Negative number:
– Step1: Assign negative value to the weight of the sign bit.
– Step 2: Sum all the weights where there are 1s.
– Step 3: Add 1 to the result.
• Example: 111010002
Step 1: -27 26 25 24 23 22 21 20
1 1 1 0 1 0 0 0
Step 2: -128+64+32+8=-24
Step 3: -24+1=-23
• Assign negative value to the weight of the sign
bit.
• Sum all the weights where there are 1s.
• Example: 101010102
Step 1: -27 26 25 24 23 22 21 20
1 0 1 0 1 0 1 0
Step 2: -128+32+8+2=-86
Decimal Value of 2’s Complement Number
Range of Unsigned Integer Numbers
• The maximum decimal number that can be
represented by n-bit is
– 2n-1
• 8-bit
– The maximum decimal number is 28-1=255
Range of SIGNED Integer Numbers
• The smallest decimal number that can be
represented by n-bit is -(2n-1)
• The biggest decimal number that can be
represented by n-bit is +(2n-1-1)
• The range is -(2n-1) to +(2n-1-1).
• Example: 8-bit
– The range is -27 to 27-1 or -128 to +127
73
Chapter 2
Number Systems
iv. Binary Codes
v. Representation of Negative Numbers
vi. Arithmetic operations
Outline
• Arithmetic Operations of 2’s Complement
– Addition
– Subtraction
– Overflow
• Simpler addition scheme makes 2’s
Complement the most common choice for
integer number systems within digital systems
Addition and Subtraction : 2’s Complement
4
+ 3
7
0100
+ 0011
0111
-4
+ 3
-1
1100
0011
1111
• Example: 4-bit system
• Example: Overflow in 4-bit system
4
- 3
1
0100
+ 1101
10001
Discard
carry
7
+ 4
11
0111
+ 0100
1011
Wrong sign
-4
+ (-3)
-7
1100
+ 1101
11001
Discard
carry
Wrong magnitude
•Does overflow occur for
this case if this is an 8-bit
system?
• Carry in sign different
from carry out sign, a sign
that overflow occurs.
2’s Complement Overflow
Overflow
Overflow when carry in to sign does not equal carry out
Expected 0 1 1 1 Actual
+5 0 1 0 1
+ +3 0 0 1 1
+8 1 0 0 0 -8
Expected 1 0 0 0 Actual
-7 1 0 0 1
+ -2 1 1 1 0
-9 1 0 1 1 1 +7
Overflow
Expected 0 0 0 0 Actual
+5 0 1 0 1
+ +2 0 0 1 0
+7 0 1 1 1 +7
No Overflow
Expected 1 1 1 1 Actual
-3 1 1 0 1
+ -5 1 0 1 1
-8 1 1 0 0 0 -8
No Overflow
• Add two positive numbers but get a negative
number
• or two negative numbers but get a positive
number
Overflow Condition
ExampleExample
Add two numbers in two’s complement
representation: (-35) + (+20) (-15)
Addition and Subtraction : 2’s Complement
ExampleExample
Add two numbers in two’s complement
representation: (-35) + (+20) (-15)
SolutionSolution
Carry 1 1 1
1 1 0 1 1 1 0 1
++ 0 0 0 1 0 1 0 0
----------------------------------
Result 1 1 1 1 0 0 0 1 -15
Addition and Subtraction : 2’s Complement
Overflow Condition
ExampleExample
Add two numbers in two’s complement
representation: (+127) + (+3) (+130)
Overflow Condition
ExampleExample
Add two numbers in two’s complement
representation: (+127) + (+3) (+130)
SolutionSolution
Carry 1 1 1 1 1 1 1
0 1 1 1 1 1 1 1
++ 0 0 0 0 0 0 1 1
----------------------------------
Result 1 0 0 0 0 0 1 0 --126 (Error)126 (Error)
An overflow has occurred.An overflow has occurred.

More Related Content

What's hot

Number system and codes
Number system and codesNumber system and codes
Number system and codesAbhiraj Bohra
 
Number system....
Number system....Number system....
Number system....mshoaib15
 
Floating point representation
Floating point representationFloating point representation
Floating point representationmissstevenson01
 
Binary number system
Binary number systemBinary number system
Binary number systemNadeem Uddin
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital ElectronicsJanki Shah
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes VandanaPagar1
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersMohammad Bashartullah
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decodersGaditek
 
binary number system
 binary number system binary number system
binary number systemvishal gupta
 
Number system
Number systemNumber system
Number systemSajib
 

What's hot (20)

Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
Number system....
Number system....Number system....
Number system....
 
Number system
Number systemNumber system
Number system
 
Floating point representation
Floating point representationFloating point representation
Floating point representation
 
Binary number system
Binary number systemBinary number system
Binary number system
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
 
Binary true ppt
Binary true pptBinary true ppt
Binary true ppt
 
Bcd
BcdBcd
Bcd
 
Digital Logic & Design
Digital Logic & DesignDigital Logic & Design
Digital Logic & Design
 
Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes Digital Electronics- Number systems & codes
Digital Electronics- Number systems & codes
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
Number System
Number SystemNumber System
Number System
 
Number system conversion
Number system conversionNumber system conversion
Number system conversion
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Encoders and decoders
Encoders and decodersEncoders and decoders
Encoders and decoders
 
binary number system
 binary number system binary number system
binary number system
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Number system
Number systemNumber system
Number system
 
Binary codes
Binary codesBinary codes
Binary codes
 

Similar to Number system utm notes

Similar to Number system utm notes (20)

number system 1.pptx
number system 1.pptxnumber system 1.pptx
number system 1.pptx
 
Alu1
Alu1Alu1
Alu1
 
Number systems r002
Number systems  r002Number systems  r002
Number systems r002
 
Number systems
Number systemsNumber systems
Number systems
 
Digital Logic Design.pptx
Digital Logic Design.pptxDigital Logic Design.pptx
Digital Logic Design.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Standard 9th Number System Power point presentation
Standard 9th Number System Power point presentationStandard 9th Number System Power point presentation
Standard 9th Number System Power point presentation
 
DATA REPRESENTATION.pptx
DATA REPRESENTATION.pptxDATA REPRESENTATION.pptx
DATA REPRESENTATION.pptx
 
digitalelectronics.ppt
digitalelectronics.pptdigitalelectronics.ppt
digitalelectronics.ppt
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
chapter 3 number systems register transfer
chapter 3 number systems register transferchapter 3 number systems register transfer
chapter 3 number systems register transfer
 
Chapter1b
Chapter1bChapter1b
Chapter1b
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
COA unit 2.pptx
COA unit 2.pptxCOA unit 2.pptx
COA unit 2.pptx
 
DCF QNA edited
DCF QNA editedDCF QNA edited
DCF QNA edited
 
Cse115 lecture01numbersystems
Cse115 lecture01numbersystemsCse115 lecture01numbersystems
Cse115 lecture01numbersystems
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 

More from Kurenai Ryu

Jif 317 2015/2016 webex 1 slides
Jif 317 2015/2016 webex 1 slidesJif 317 2015/2016 webex 1 slides
Jif 317 2015/2016 webex 1 slidesKurenai Ryu
 
Academic planner jif 315 20152016
Academic planner jif 315   20152016Academic planner jif 315   20152016
Academic planner jif 315 20152016Kurenai Ryu
 
Jif315 academic planner
Jif315 academic plannerJif315 academic planner
Jif315 academic plannerKurenai Ryu
 
Jif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformJif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformKurenai Ryu
 
Chap1 special relativty
Chap1 special relativtyChap1 special relativty
Chap1 special relativtyKurenai Ryu
 
Module 2 jif 104 liquid
Module 2 jif 104 liquidModule 2 jif 104 liquid
Module 2 jif 104 liquidKurenai Ryu
 
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1Kurenai Ryu
 
Material Science SNU korea chapter 1
Material Science SNU korea chapter 1Material Science SNU korea chapter 1
Material Science SNU korea chapter 1Kurenai Ryu
 

More from Kurenai Ryu (10)

Multsim pertama
Multsim pertamaMultsim pertama
Multsim pertama
 
Jif 317 2015/2016 webex 1 slides
Jif 317 2015/2016 webex 1 slidesJif 317 2015/2016 webex 1 slides
Jif 317 2015/2016 webex 1 slides
 
Academic planner jif 315 20152016
Academic planner jif 315   20152016Academic planner jif 315   20152016
Academic planner jif 315 20152016
 
Laplace1
Laplace1Laplace1
Laplace1
 
Jif315 academic planner
Jif315 academic plannerJif315 academic planner
Jif315 academic planner
 
Jif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transformJif 315 lesson 1 Laplace and fourier transform
Jif 315 lesson 1 Laplace and fourier transform
 
Chap1 special relativty
Chap1 special relativtyChap1 special relativty
Chap1 special relativty
 
Module 2 jif 104 liquid
Module 2 jif 104 liquidModule 2 jif 104 liquid
Module 2 jif 104 liquid
 
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1
Chapter Atomic Structure and Interatomic Bonds (Jif 104 Chpter 1
 
Material Science SNU korea chapter 1
Material Science SNU korea chapter 1Material Science SNU korea chapter 1
Material Science SNU korea chapter 1
 

Recently uploaded

Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 

Recently uploaded (20)

Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 

Number system utm notes

  • 1. 1 Chapter 2 Number Systems i. Decimal, Binary, Hexadecimal, Octal ii. Number conversions iii. Binary Arithmetic
  • 2. 2 Digital Number Systems • Many number systems are used in digital electronics. – Decimal number system – Binary number system – Octal number system – Hexadecimal number system
  • 3. 3 Decimal System • We use decimal numbers everyday • Base-10 system • 10 symbols: 0,1,2,3,4,5,6,7,8,9 • Examples: 23, 5, 7, 88.9, 0.2
  • 4. 4 Decimal System • The position of each digit in a decimal number can be assigned a weight • For example: 2745.214 – 2745.214 is a decimal number – 2 is a digit, 7 is a digit, 4 is a digit… 2 7 4 5 2 1 4. 103 102 101 100 10-110-210-3 weights
  • 5. 5 Decimal System 2745.21410 = (2x103) + (7x102) + (4x101) + (5x100) + (2x10-1) + (1x10-2) + (4x10-3) 2 7 4 5 2 1 4. 103 102 101 100 10-110-210-3 weights
  • 6. 6 Decimal System • Most significant digit (MSD)—the digit that carries the most weight • Least significant digit (LSD)– the digit that carries the least weight 2 7 4 5 2 1 4. 103 102 101 100 10-110-210-3 weights
  • 7. 7 Decimal Counting • 0 1 2 3 4 5 6 7 8 9----- 10 11---------------------------- 19---- 20---- ------------------------------- 99---- 100------------ ------
  • 8. 8 Binary System • Difficult to design a system that works with 10 different voltage levels • Base-2 system • 2 digits/symbols: 0, 1 • Examples: 0, 1, 01, 111, 101010 • Similar to decimal number, the position of each digit in a binary number can be assigned a weight.
  • 9. 9 Binary System • The position of each digit (bit) in a binary number can be assigned a weight • For example: 1011.101 – 1011.101 is a binary number – 1 is a digit, 0 is a digit, 1 is a digit… 1 0 1 1 1 0 1. 23 22 21 20 2-1 2-2 2-3 weights
  • 10. 10 Binary System 1011.1012=(1x23) + (0x22) + (1x21) + (1x20) + (1x2-1) + (0x2-2) + (1x2-3) = 8 + 0 + 2 + 1 + 0.5 + 0 + 0.125 = 11.62510 1 0 1 1 1 0 1. 23 22 21 20 2-1 2-2 2-3 weights
  • 11. 11 Binary counting • 0 1 10 11 100 101 110 111-------- --------- 11111
  • 12. 12 Hexadecimal System • Base-16 system • 16 symbols: 10 numeric digits and 6 alphabetic characters – 0,1,2,3,4,5,6,7,8,9 – A,B,C,D,E,F • Compact way of writing binary number • Widely used in computer and microprocessor applications
  • 13. 13 Hexadecimal System • Examples: 1C16 , A8516 • 1CH, A85H • The position of each digit in a hexadecimal number can be assigned a weight • For example: 2AF8.98E – 2AF8.98E is a hexadecimal number – 2 is a digit, A is a digit, F is a digit… 2 A F 8 9 8 E. 163 162 161 160 16-116-216-3 weights
  • 14. 14 Hexadecimal Counting • 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12------------------- 19 1A--------------------------------------- FF 100 101 102------------------
  • 15. 15 Octal System • Base-8 system • 8 digits: 0,1,2,3,4,5,6,7 • Convenient way to express binary numbers and codes. Use 3 bits of binary
  • 16. 16 Table of Number Systems DECIMAL BINARY HEXADECIMAL OCTAL 0 0000 0 0 1 0001 1 1 2 0010 2 2 3 0011 3 3 4 0100 4 4 5 0101 5 5 6 0110 6 6 7 0111 7 7 8 1000 8 10 9 1001 9 11 10 1010 A 12 11 1011 B 13 12 1100 C 14 13 1101 D 15 14 1110 E 16 15 1111 F 17
  • 17. 17 Review • Give the largest decimal number that can be represented in binary with 8 bits. • Determine the weight of the 1 in 100002. • Convert the binary number 10111101.0112 to decimal. Ans:189.37510
  • 18. 18 Conversions • Binary Decimal • Decimal Binary • Hexadecimal Decimal • Decimal Hexadecimal • Binary Hexadecimal • Hexadecimal Binary • Octal Decimal • Decimal Octal • Binary Octal • Octal Binary
  • 19. 19 BINARY number DECIMAL number Method 1: Sum-of-Weights Binary Decimal Given 110012 S1: write the weights 1 1 0 0 1Binary number weights 2021 222324 S2: write the sum of the products of each digit with its weight 110012 =(1x24)+(1x23)+(0x22)+(0x21)+(1x20) =16 + 8 + 1 =2510 Binary Decimal ? Answer: 2510
  • 20. 20 Decimal Binary Conversion • Decimal number binary number – Method: sum-of-weights • Decimal whole number binary number – Method: division-by-2 • Decimal fraction binary number – Method: multiplication-by-2
  • 21. 21 DECIMAL number BINARY number Method 1: Sum-of-Weights Decimal Binary Given 2510 Step 1: Find the power of two that fulfills the following: a. nearest to the given decimal number; and b. its decimal number is less than or equal to the given decimal number. 22? No, because it is not the nearest. 8 (23) is nearer and still less than 25. 25? No, because its decimal number, 32 is more than 25. 24? Yes, because it is the nearest and its decimal, 16 is less than 25. Step 2: Subtract the power of two (from Step 1) from the given decimal number. 25-16=9 The result of the subtraction is 9. Step 3: If the result of the subtraction in Step 2 is 0, go to Step 4. Else, repeat Steps 1 and 2 for the result of the subtraction in Step 2. Step 4: Write out the binary number based on all the powers of two from Step 1.
  • 22. 22 DECIMAL Number BINARY Number Method 1: Sum-of-Weights Given 5110 • Step 1: the power of two which is nearest to 51 but less than 51 is 25 • Step 2: the result of subtraction 51-32=19 • Step 3: – Repeat Step 1: the power of two nearest to 19 but less than 19 is 24 – Repeat Step 2: the result of subtraction 19-16=3 – Repeat Step 1: the power of two which is nearest to 3 and less than 3 is 21 – Repeat Step 2: the result of subtraction 3-2=1 – Repeat Step 1: the power of two which is nearest to 1 and equal to 1is 20 – Repeat Step 2: the result of subtraction 1-1=0 • Step 4: 1 0 0 1 1Binary number Weights 24 23 22 21 20 1 25
  • 23. 23 DECIMAL Number BINARY Number Method 2: Repeated Division-by-2 • Method 1 can convert both whole numbers and fractional numbers to binary. • Method 2 is to convert whole numbers to binary. • Given 4510 – Repeat the division until the quotient is 0. 22 2 45 = Remainder 11 2 22 = 5 2 11 = 2 2 5 = 1 2 2 = 0 2 1 = Quotient 1 0 1 1 0 1 LSB MSB The binary number is 1011012
  • 24. 24 DECIMAL fraction BINARY fraction Method 3: Repeated Multiplication-by-2 • Method 3 is to convert decimal fraction to binary. • Repeat the multiplication until the fractional part is all zeros. • Given 0.3125 0.3125 x 2 = 0.625 0.625 x 2 = 1.25 0.25 x 2 = 0.50 0.50 x 2 = 1.00 Carry 0 1 0 1 MSB LSB The binary fraction is .0101
  • 25. 25 DECIMAL Number HEXADECIMAL Number Method: Repeated division-by-16 • Repeat the division until the quotient is 0. • Example: 65010 40 16 650 = 2 16 40 = 0 16 2 = quotient Remainder (decimal) Remainder (hexadecimal) LSD MSD A 8 2 10 8 2 So, the hexadecimal number is 28A16
  • 26. 26 BINARY Number HEXADECIMAL Number • Step 1: Break the binary number into 4-bit groups, starting from LSB. • Step 2: Replace each 4-bit with the equivalent hexadecimal number. • Example: 111111000101101001 00111111000101101001binary hexadecimal 961F3 The hexadecimal number is 3F16916
  • 27. 27 HEXADECIMAL Number BINARY Number • Step: Replace each digit of the hexadecimal number with the equivalent 4-bit binary number. • Example: CF8E16 C F 8 EHexadecimal Binary 1110100011111100 The binary number is 11001111100011102
  • 28. 28 DECIMAL Number OCTAL Number Method: Repeated division-by-8 • Repeat the division until the quotient is 0. • Example: 35910 44 8 359 = 5 8 44 = 0 8 5 = quotient Remainder LSD MSD 7 4 5 So, the octal number is 5 4 78
  • 29. 29 BINARY Number OCTAL Number • Step 1: Break the binary number into 3-bit groups, starting from LSD. • Step 2: Replace each 3-bit group with the equivalent octal number. • Example: 1101012 110101binary octal 56 The octal number is 658
  • 30. 30 OCTAL Number BINARY Number • Step: Replace each octal digit with the equivalent 3-bit group. • Example: 138 Octal Binary 1 3 001 011 So, the binary number is 0010112
  • 31. 31 Exercise • Fill in the blanks. Decimal Binary Hexadecimal Octal 1101.0112 10101.112 245.62510 70310 A8516
  • 32. 32 Exercise • Answers Decimal Binary Hexadecimal Octal 13.37510 1101.0112 D.616 15.38 21.7510 10101.112 15.C16 25.68 245.62510 11110101.1012 F5.A16 365.58 70310 10101111112 2BF16 12778 269310 1010100001012 A8516 52058
  • 33. Binary Arithmetic • Binary addition • Binary subtraction • Binary multiplication • Binary division
  • 34. Binary addition • 0 + 0 = 0 with a carry of 0 • 0 + 1 = 1 with a carry of 0 • 1 + 0 = 1 with a carry of 0 • 1 + 1 = 10 with a carry of 1 • Example: 111 + 11 = ? 111 7 + 11 +3 1010 10 In decimal…
  • 35. Binary subtraction • 0 – 0 = 0 • 1 – 1 = 0 • 1 – 0 = 1 • 10 – 1 = 1 • Example: 101 – 11 = ? 101 5 - 11 -3 10 2 In decimal
  • 36. Binary Multiplication • 0 x 0 = 0 • 0 x 1 = 0 • 1 x 0 = 0 • 1 x 1 = 1 • Example: 101 x 111 = ? 101 5 x 111 x7 101 35 101 101 100011
  • 37. Binary Division • The procedure is same as decimal division • Examples: 110 ÷ 11 =? 110 11 0 0 11 10 6 6 0 3 2 In decimal…
  • 38. Review • Why binary numbers? Why not decimal? – Digital system understand binary numbers, not decimal numbers.
  • 39. Review • Why hexadecimal? – Shorthand of binary numbers – Easy to convert to and from binary • Examples: – 1 1111 1000 0000 1010 1000 00012 – 1F80A8116
  • 40. 40 Chapter 2 Number Systems iv. Binary Codes v. Representation of Negative Numbers vi. Arithmetic operations
  • 41. 41 Chapter 2 Number Systems iv. Binary Codes v. Representation of Negative Numbers vi. Arithmetic operations
  • 42. Outline • Binary Codes – BCD 8421 – Gray – ASCII – EBCDIC
  • 43. Code and Encoding • Code-- Special group of symbols that is used to represent numbers, letters or words. • Encoding– The process of converting a number/letter/word into a code. Number, Letter, Word encoding Code Generally, For example, Numbers, Letters, Words Straight binary coding Binary number
  • 44. Other Codes • External world is decimal but digital systems use binary numbers. – So, conversions are often. • Other codes are introduced because the conversion between the code and the decimal number is easier.
  • 45. BCD Code • Binary Coded Decimal Code • Binary Coded Decimal (BCD)—a way to represent each digit of a decimal number with its 4-bit binary number. Example: 87410 8 7 4Decimal BCD 1000 0111 0100 Therefore, the BCD code for 87410 is 1000 0111 0100 Do you know why? 1000 1111 is not a BCD
  • 46. BCD Code / 8421 Code • Convert a BCD code to its decimal equivalent. – Step 1: Break the BCD into 4-bit groups, starting from LSB – Step 2: Replace each 4-bit group with its equivalent decimal • Example: 0110 1000 0011 1001 6 8 3 9 So, the decimal equivalent is 683910
  • 47. BCD coding vs. straight binary coding • BCD coding is easier. Decimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 BCD coding 13710 13710 1 3 7decimal BCD 0001 0011 0111 The BCD code is 0001 0011 0111 137 2 68 2 =68 1 =34 0 34 2 =17 0 =8 117 2 8 2 =4 0 4 2 =2 0 2 2 =1 0 1 2 =0 1 The straight binary code is 100010012
  • 48. Gray Code • No weights assigned to the bit positions • Only a single bit change from one code word to the next in sequence. • Good— minimize the chance for error. DECIMAL BINARY GRAY CODE 0 0000 0000 1 0001 0001 2 0010 0011 3 0011 0010 4 0100 0110 5 0101 0111 6 0110 0101 7 0111 0100 8 1000 1100 9 1001 1101 10 1010 1111 11 1011 1110 12 1100 1010 13 1101 1011 14 1110 1001 15 1111 1000
  • 49. Conversions BINARY TO GRAY CONVERSION 1---+--->1 ---+--->0---+--->1---+--->1 1 0 1 1 0 GRAY TO BINARY CONVERSION 1 1 0 1 1 1 0 0 1 0 Binary Gray Gray Binary
  • 50. Alphanumeric codes • Codes that represent numbers and alphabetic characters (letters). • At minimum, the code must represent 10 decimal digits (0-9) and 26 letters (A-Z). • 6 bits are needed in the code that represent the numbers and letters. • ASCII is the most common alphanumeric code.
  • 51. ASCII Code • American Standard Code for International Interchange • Used in computers and electronic equipment processor 1011001
  • 52. ASCII Code • ASCII code has 128 characters and symbols • Represented by 7-bit binary code • Can be considered an 8-bit code with MSB 0. • The first 32 ASCII characters are non-graphic commands only for control purposes—The ASCII Control Characters. • E.g.: null, line feed, start of text, escape
  • 54. Character or Number ASCII-8 Binary EBCDIC Binary A 01000001 11000001 E 01000101 11000101 Z 01011010 11101001 0 00110000 11110000 1 00110001 11110001 5 00110101 11110101 EBCDIC ALPHANUMERIC CODE Extended Binary Coded Decimal Interchange Code •8-bit character encoding
  • 56. 56 Chapter 2 Number Systems iii. Binary Codes iv. Representation of Negative Numbers v. Arithmetic operations
  • 57. Outline • Representation of negative numbers – Sign and magnitude – 1’s complement – 2’s complement
  • 58. Representation of negative numbers • Computer must handle both positive and negative numbers. • A signed binary number consists of both sign and magnitude information. • 3 types of representation: – Sign and magnitude (least used) – 1’s complement – 2’s complement (most important)
  • 59. Sign and Magnitude • The sign bit—the left-most bit in a signed binary number – A ‘0’ sign bit indicates a positive number – A ‘1’ sign bit indicates a negative number • The remaining bits are the magnitude bits. • Example: Express the decimal number -39 as an 8-bit number in the sign-magnitude. 3910=1001112= 0010 01112 The sign bit is 1. Therefore, -3910= 1010 01112
  • 61. 1’s complement • To find the 1’s complement of a given binary number, – Change all 1s to 0s and all 0s to 1s. • Example: Find the 1’s complement of 10110010 1 0 1 1 0 0 1 0 0 1 0 0 1 1 0 1
  • 63. 2’s complement • To find the 2’s complement of a given binary number, – Add 1 to the LSB of the 1’s complement • Example: Find the 2’s complement of 10110010 A 10110010 Binary number 01001101 1’s complement + 1 add 1 01001110 2’s complement B 10110010 01001110
  • 64. 2’s Complement 0000 0111 0011 1011 1111 1110 1101 1100 1010 1001 1000 0110 0101 0100 0010 0001 +0 +1 +2 +3 +4 +5 +6 +7-8 -7 -6 -5 -4 -3 -2 -1 0 100 = + 4 1 100 = - 4 + - • Only one representation for 0 • One more negative number than positive number
  • 65. Comparison +19 -19 Sign-magnitude 1’s complement 2’s complement Exercise: Express the decimal numbers +19 and -19 as an 8-bit number in the sign-magnitude, 1’s complement and 2’s complement forms.
  • 66. Comparison +19 -19 Sign-magnitude 00010011 10010011 1’s complement 00010011 11101100 2’s complement 00010011 11101101 Exercise: Express the decimal numbers +19 and -19 as an 8-bit number in the sign-magnitude, 1’s complement and 2’s complement forms.
  • 68. Decimal Value of Sign-Magnitude Number • Convert the magnitude bits to its decimal value. • The sign bit determines whether the number is positive or negative. • Example: 100101012 00101012 = 24 + 22 + 20 = 16 + 4 + 1 = 21 The sign bit is 1. Therefore, the decimal number is -21.
  • 69. Decimal Value of 1’s Complement Number • Positive number: – Sum the weights of all bit position where there are 1s. • Negative number: – Step1: Assign negative value to the weight of the sign bit. – Step 2: Sum all the weights where there are 1s. – Step 3: Add 1 to the result. • Example: 111010002 Step 1: -27 26 25 24 23 22 21 20 1 1 1 0 1 0 0 0 Step 2: -128+64+32+8=-24 Step 3: -24+1=-23
  • 70. • Assign negative value to the weight of the sign bit. • Sum all the weights where there are 1s. • Example: 101010102 Step 1: -27 26 25 24 23 22 21 20 1 0 1 0 1 0 1 0 Step 2: -128+32+8+2=-86 Decimal Value of 2’s Complement Number
  • 71. Range of Unsigned Integer Numbers • The maximum decimal number that can be represented by n-bit is – 2n-1 • 8-bit – The maximum decimal number is 28-1=255
  • 72. Range of SIGNED Integer Numbers • The smallest decimal number that can be represented by n-bit is -(2n-1) • The biggest decimal number that can be represented by n-bit is +(2n-1-1) • The range is -(2n-1) to +(2n-1-1). • Example: 8-bit – The range is -27 to 27-1 or -128 to +127
  • 73. 73 Chapter 2 Number Systems iv. Binary Codes v. Representation of Negative Numbers vi. Arithmetic operations
  • 74. Outline • Arithmetic Operations of 2’s Complement – Addition – Subtraction – Overflow • Simpler addition scheme makes 2’s Complement the most common choice for integer number systems within digital systems
  • 75. Addition and Subtraction : 2’s Complement 4 + 3 7 0100 + 0011 0111 -4 + 3 -1 1100 0011 1111 • Example: 4-bit system • Example: Overflow in 4-bit system 4 - 3 1 0100 + 1101 10001 Discard carry 7 + 4 11 0111 + 0100 1011 Wrong sign -4 + (-3) -7 1100 + 1101 11001 Discard carry Wrong magnitude •Does overflow occur for this case if this is an 8-bit system? • Carry in sign different from carry out sign, a sign that overflow occurs.
  • 76. 2’s Complement Overflow Overflow Overflow when carry in to sign does not equal carry out Expected 0 1 1 1 Actual +5 0 1 0 1 + +3 0 0 1 1 +8 1 0 0 0 -8 Expected 1 0 0 0 Actual -7 1 0 0 1 + -2 1 1 1 0 -9 1 0 1 1 1 +7 Overflow Expected 0 0 0 0 Actual +5 0 1 0 1 + +2 0 0 1 0 +7 0 1 1 1 +7 No Overflow Expected 1 1 1 1 Actual -3 1 1 0 1 + -5 1 0 1 1 -8 1 1 0 0 0 -8 No Overflow
  • 77. • Add two positive numbers but get a negative number • or two negative numbers but get a positive number Overflow Condition
  • 78. ExampleExample Add two numbers in two’s complement representation: (-35) + (+20) (-15) Addition and Subtraction : 2’s Complement
  • 79. ExampleExample Add two numbers in two’s complement representation: (-35) + (+20) (-15) SolutionSolution Carry 1 1 1 1 1 0 1 1 1 0 1 ++ 0 0 0 1 0 1 0 0 ---------------------------------- Result 1 1 1 1 0 0 0 1 -15 Addition and Subtraction : 2’s Complement
  • 80. Overflow Condition ExampleExample Add two numbers in two’s complement representation: (+127) + (+3) (+130)
  • 81. Overflow Condition ExampleExample Add two numbers in two’s complement representation: (+127) + (+3) (+130) SolutionSolution Carry 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 ++ 0 0 0 0 0 0 1 1 ---------------------------------- Result 1 0 0 0 0 0 1 0 --126 (Error)126 (Error) An overflow has occurred.An overflow has occurred.