0% found this document useful (0 votes)
6 views

2 Binary Arithmetic

The document covers digital logic design focusing on binary arithmetic operations such as addition, subtraction, and multiplication, along with the representation of negative numbers using signed-magnitude, 2's complement, and 1's complement methods. It also discusses binary-coded decimal (BCD) and other decimal codes, including Gray code and ASCII, highlighting their applications in digital systems. The examples provided illustrate how binary arithmetic is performed and how different number representations are utilized in logic circuits.

Uploaded by

anashazem467
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

2 Binary Arithmetic

The document covers digital logic design focusing on binary arithmetic operations such as addition, subtraction, and multiplication, along with the representation of negative numbers using signed-magnitude, 2's complement, and 1's complement methods. It also discusses binary-coded decimal (BCD) and other decimal codes, including Gray code and ASCII, highlighting their applications in digital systems. The examples provided illustrate how binary arithmetic is performed and how different number representations are utilized in logic circuits.

Uploaded by

anashazem467
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Digital Logic Design

01 - Number Systems and Codes


Binary Arithmetic
Addition
• Decimal Addition

24
Addition
• Arithmetic operations in digital systems are usually done in binary
• Design of logic circuits for binary arithmetic is much easier than for
decimal

• The addition table for binary numbers is





• and carry 1 to the next column

25
Addition
• Binary Addition

26
Addition
• Example: 1101 + 1011
• Answer: 11000

• Example: 101101 + 100111


• Answer: 1010100

27
Subtraction
• Decimal subtraction

28
Subtraction
• Decimal subtraction

29
Subtraction
• The subtraction table for binary numbers is

• and borrow 1 from the next column

• Borrowing 1 from a column is equivalent to subtracting 1 from that


column

30
Subtraction
• Binary Subtraction

31
Subtraction
• Example: 11101 – 10011
• Answer: 1010

• Example: 111001 – 1011


• Answer: 101110

• Example: 10000 – 11
• Answer: 1101

32
Multiplication
• Decimal Multiplication

33
Multiplication
• The multiplication table for binary numbers is



• Multiplication is done bit by bit

34
Multiplication

35
Multiplication
• Example: 1011 * 101
• Answer: 110111

• Example: 1101 * 1011


• Answer: 10001111

36
Representation of Negative Numbers
Representation of Negative Numbers
• To represent negative integers, a notation for the negative values
is needed
• It is customary to represent the sign with a bit placed in the
leftmost position of the binary number
• The convention is to make the sign bit 0 for positive and 1 for
negative
• The most common methods for representing both positive and
negative numbers are:
• Signed-magnitude
• 2’s complement
• 1’s complement

38
Signed-Magnitude Numbers
• Consider an n-bit sign and magnitude number
bit 0
0 +ve bit 1 bit 2 … bit n-2 bit n-1
1 -ve

• 1 bit for the sign and n-1 bits for the magnitude
• Number in the range to are represented
• Including +0 and -0

• Designing logic circuits to perform arithmetic on sign and magnitude is not


easy
39
Signed-Magnitude Numbers

• Can represent numbers between -7 and +7
+𝑁 Positive Integers −𝑁 Sign and
Magnitude
+0 0000 -0 1000
+1 0001 -1 1001
+2 0010 -2 1010
+3 0011 -3 1011
+4 0100 -4 1100
+5 0101 -5 1101
+6 0110 -6 1110
+7 0111 -7 1111
40
2’s Complement Numbers
• Consider n-bits numbers
• A positive number is represented by a 0 followed by the magnitude of
• A negative number is represented by its 2’s complement ∗ , where

• The magnitude of a negative number can be obtained by taking it’s 2’s


complement

• The range of representable numbers is to


41
1’s Complement Numbers
• For binary numbers, r = 2 and r - 1 = 1, so the 1’s complement of N is (2n - 1) - N. Again,
2n is represented by a binary number that consists of a 1 followed by n 0’s.
• 2n - 1 is a binary number represented by n 1’s.
• For Example: if n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2. Thus, the 1’s
complement of a binary number is obtained by subtracting each digit from 1.
However, when subtracting binary digits from 1, we can have either 1 - 0 = 1 or 1 - 1 =
0, which causes the bit to change from 0 to 1 or from 1 to 0, respectively. Therefore,
the 1’s complement of a binary number is formed by changing 1’s to 0’s and 0’s to 1’s.
The following are some numerical examples:
The 1’s complement of 1011000 is 0100111.
The 1’s complement of 0101101 is 1010010. 42
2’s Complement Numbers
• Examples:
2’s Complement Numbers
• Examples:
2’s Complement Numbers

• Can represent the numbers between -8 and +7
+𝑁 Positive Integers −𝑁 2’s Complement
+0 0000 -0 ____
+1 0001 -1 1111
+2 0010 -2 1110
+3 0011 -3 1101
+4 0100 -4 1100
+5 0101 -5 1011
+6 0110 -6 1010
+7 0111 -7 1001
-8 1000
45
Addition of 2’s Complement Numbers
• Addition is carried out as if all the numbers were positive, and any
carry form the sign position is ignored
• This will always yield the correct result except when an overflow
occurs
• An overflow occurs when the correct representation of the sum
(including the sign) requires more than bits

• Assume , the different cases will be illustrated in the next


pages

46
Addition of 2’s Complement Numbers
1. Addition of two positive numbers, sum

2. Addition of two positive numbers, sum

47
Addition of 2’s Complement Numbers
3. Addition of positive and negative numbers (negative number has a
greater magnitude)

4. Addition of positive and negative numbers (positive number has a


greater magnitude)

48
Addition of 2’s Complement Numbers
5. Addition of two negative number, |sum|

6. Addition of two negative numbers, |sum|

49
Binary Codes for Decimal Numbers
Binary Codes for Decimal Numbers
• Digital systems use signals that have two distinct values and circuit
elements that have two stable states
• There is a direct analogy between binary signals, binary circuit
elements, and binary digits
• However, the input and output equipment generally use decimal
numbers
• Therefore, decimal numbers must be coded in terms of binary signals

51
Binary-Coded Decimal (BCD) Code
• Each decimal digit is replaced by its binary equivalent

• A number with decimal digits will require bits in BCD.


• A decimal number in BCD is the same as its equivalent binary number only
when the number is between 0 and 9
• The binary combinations 1010 through 1111 are not used and have no
meaning in BCD

52
Binary-Coded Decimal (BCD) Code
• A decimal number in BCD is
the same as its equivalent
binary number only when
the number is between 0
and 9
• The binary combinations
1010 through 1111 are not
used and have no meaning
in BCD

53
Other Decimal Codes

54
Gray Code
• Used in applications in which the
normal sequence of binary numbers
generated by hardware may produce
errors or ambiguity during the
transition from one number to the
next
• In Gray code, only one bit changes its
value during any transition between
two numbers

55
ASCII Code
• American Standard Code for Information Interchange (ASCII) Character
Code
• A popular code used to represent information sent as character-based
data.
• It uses 7-bits to represent:
• 94 Graphic printing characters.
• 34 Non-printing characters.
• Some non-printing characters are used for text format (e.g. BS =
Backspace, CR = carriage return).
• Other non-printing characters are used for record marking and flow
control (e.g. STX and ETX start and end text areas).

56
ASCII Code

57

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