0% found this document useful (0 votes)
1 views36 pages

Module2_I_Number Systems and Arithmetic.pdf

The document covers fundamental concepts in digital electronics, focusing on number systems, binary arithmetic, and signed numbers. It explains binary and decimal conversions, arithmetic operations, and the representation of signed numbers using different methods like sign-magnitude, 1's complement, and 2's complement. Additionally, it discusses the implications of overflow in binary addition and subtraction operations.
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)
1 views36 pages

Module2_I_Number Systems and Arithmetic.pdf

The document covers fundamental concepts in digital electronics, focusing on number systems, binary arithmetic, and signed numbers. It explains binary and decimal conversions, arithmetic operations, and the representation of signed numbers using different methods like sign-magnitude, 1's complement, and 2's complement. Additionally, it discusses the implications of overflow in binary addition and subtraction operations.
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/ 36

DIGITAL ELECTRONICS

Number Systems, Operations, and Codes


OUTLINE
• Binary Numbers
• Decimal Numbers
• Decimal-to-Binary Conversion
• Binary Arithmetic
• Complements of Binary Numbers
• Signed Numbers
• Arithmetic Operations with Signed Numbers
• Hexadecimal Numbers
• Octal Numbers
• Binary Coded Decimal (BCD)
• Digital Codes
DECIMAL NUMBERS
• The decimal number system has ten digits.
0 The decimal number
system has a base of
1 10

2
3
4
5 weight
6
7
8
9
DECIMAL NUMBERS
• Express the decimal number 47 as a sum of the values of each digit.

• Express the decimal number 568.23 as a sum of the values of each digit
BINARY NUMBERS
• The binary number system has two digits (bits).
• Largest decimal number = 2n- 1
0 The binary number system has a base of 2
• For example, with five bits (n = 5) you can
1 count from zero to thirty-one.
25 - 1 = 32 - 1 = 31
DEC BIN • With six bits (n = 6) you can count from
0 0 zero to sixty-three.
1 1 26 - 1 = 64 - 1 = 63

2 10 number of number of
bits combinations bits combinations
3 11 1 1 64 1.8E+19
2 3 128 3.4E+38
4 100 3 7 256 1.2E+77
5 101 4 15
5 31
6 110
6 63
7 111 7 127
8 1000 8 255
16 65535
9 1001 32 4E+09
THE WEIGHTING STRUCTURE OF BINARY NUMBERS
• LSB (least significant bit)
• MSB (most significant bit)

L1
BINARY-TO-DECIMAL CONVERSION
• Convert the binary whole number 1101101 to decimal.

• Convert the fractional binary number 0.1011 to decimal


DECIMAL-TO-BINARY CONVERSION
Sum-of-Weights Method

• list of seven binary weights would be 64, 32,16, 8, 4, 2, 1


EXAMPLE

EXAMPLE
EXAMPLE
Repeated Division-by-2 Method
converting the decimal number 12 to binary
Converting Decimal Fractions to Binary

Repeated Multiplication by 2
0.3125 to binary
BINARY ARITHMETIC
addition of 11 + 1

• Add binary numbers


• Subtract binary numbers
• Multiply binary numbers
• Divide binary numbers EXAMPLE

Binary Addition

In binary 1+1 = 10, not 2.


Binary Subtraction EXAMPLE

In binary 10 - 1 = 1, not 9.

EXAMPLE
Subtract 011 from 101.
Half adder, Full adder:
Half subtractor, Full subtractor:
Binary Multiplication Binary Division
The four basic rules for multiplying bits are as follows: EXAMPLE

EXAMPLE
COMPLEMENTS OF BINARY NUMBERS
• The 1’s complement and the 2’s complement of a binary number are important
because they permit the representation of negative numbers.
• The method of 2’s complement arithmetic is commonly used in computers to handle
negative numbers.
you should be able to
• Convert a binary number to its 1’s complement
• Convert a binary number to its 2’s complement using either of two methods
Finding the 1’s Complement

The 1’s complement of a binary number is found by


changing all 1’s to 0’s and all 0’s to 1’s,

Example of inverters used to obtain the 1’s complement of a binary


number.
Finding the 2’s Complement Alternative method
The 2’s complement of a binary number is found by adding 1 to 1. Start at the right with the LSB and write the bits
the LSB of the 1’s complement. as they are up to and including the first 1.
2. Take the 1’s complements of the remaining bits.

EXAMPLE
EXAMPLE Find the 2’s complement of 10110010.
Find the 2’s complement of 10111000 using
the alternative method.
SIGNED NUMBERS
Table lists all possible four‐bit signed binary numbers in the three representations.

Note that all negative numbers have a 1 in the leftmost bit position; that is the way we distinguish them
from the positive numbers.
In the 2’s‐complement representation, there are
eight positive numbers, including one zero,
and eight negative numbers.

In the signed‐magnitude and the


1’s‐complement representations, there are
eight positive numbers and eight negative
numbers, including two zeros

21
Range of Signed Integer Numbers
Unsigned Numbers: n-bit numbers
Total combination: 2n and the range is 0 to 2n-1

In the 2’s‐complement representation, there are eight positive numbers, including one zero, and eight negative
numbers. 2’s‐complement signed numbers, the range of values for n-bit numbers is:

𝑅𝑎𝑛𝑔𝑒 = − 2𝑛−1 𝑡𝑜 + (2𝑛−1 − 1)

In the signed‐magnitude and the 1’s‐complement representations, there are eight positive numbers and eight
negative numbers, including two zeros.

• 1’s‐complement signed numbers, the range of values for n-bit numbers is:

𝑅𝑎𝑛𝑔𝑒 = − 2𝑛−1 − 1 𝑡𝑜 + (2𝑛−1 − 1)


• Sign-Magnitude, the range of values for n-bit numbers is:

𝑅𝑎𝑛𝑔𝑒 = − 2𝑛−1 − 1 𝑡𝑜 + (2𝑛−1 − 1)


22
SIGNED NUMBERS
• Express positive and negative numbers in sign-magnitude
• Express positive and negative numbers in 1’s complement
• Express positive and negative numbers in 2’s complement
• Determine the decimal value of signed binary numbers

The Sign Bit Sign-Magnitude Form

The left-most bit in a signed binary For example, the decimal number +25 is
number is the sign bit, which tells you expressed as an 8-bit signed binary
whether the number is positive or number using the sign-magnitude form as
negative.
A 0 sign bit indicates a positive number,
and a 1 sign bit indicates a negative -25 = 10011001
number.
SIGNED NUMBERS : Signed Magnitude
1’s Complement Form +25 = 00011001
-25 = 11100110 (1’s)
2’s Complement Form
+25 = 00011001
-25 = 11100111 (1’s+1 = 2’s)
EXAMPLE
Express the decimal number +39 as an 8-bit number in the sign-magnitude, 1’s complement, and 2’s complement forms.

+39 = 00100111
-39 = 10100111 (Signed magnitude)
-39 = 11011000 (1’s)
-39 = 11011001 (2’s)
THE DECIMAL VALUE OF SIGNED NUMBERS
Sign-Magnitude Determine the decimal value of this signed binary number
expressed in sign-magnitude: 10010101.

1’s Complement EXAMPLE Determine the decimal values of the signed binary
numbers expressed in 1’s complement:
(a) 00010111 (b) 11101000
1 Byte = 8 bits
1 Nibble = 4 bits
(a) 00010111 (b) 11101000

Add +1 to the result if


weight of -27 is 1
2’s Complement Determine the decimal values of the signed binary numbers expressed in 2’s complement:
(a) 01010110 (b) 10101010

No need to make
any changes to
answer. Answer
obtained is the
final result.
ARITHMETIC OPERATIONS WITH BINARY SIGNED NUMBERS (2’S Complement)
Addition
The two numbers in an addition are the addend and the augend. The result is the sum.
There are four cases that can occur when two signed binary numbers are added.
1. Both numbers positive
2. Positive number with magnitude larger than negative number
3. Negative number with magnitude larger than positive number
4. Both numbers negative

8-bit signed numbers as examples


Both numbers positive: Positive number with magnitude larger than negative number:

The sum is positive and is


The final carry bit is discarded. The sum is positive and
therefore in true
therefore in true (uncomplemented)
(uncomplemented) binary
binary.
Negative number with Both numbers negative:
magnitude larger than positive
number:

The final carry bit is discarded. The sum is negative and


The sum is negative and therefore therefore in 2’s complement form.
in 2’s complement form.

Rules in 2’S Compliment form:

➢ If there is a carry in final sum, the final carry bit is discarded. The sum is positive and therefore in
true (uncomplemented) binary.

➢ If there is no carry in final sum, the sum is negative and therefore in 2’s complement form
Arithmetic Addition using signed‐2’s‐complement
Rule: The addition of two signed binary numbers with negative numbers represented in
signed‐2’s‐complement form is obtained from the addition of the two numbers, including their sign bits.
A carry out of the sign‐bit position is discarded.

In each of the four cases, the operation performed is addition with the sign bit included. Any carry out of the
sign‐bit position is discarded, and negative results are automatically in 2’s‐complement form.

31
Arithmetic Addition using signed‐2’s‐complement
Overflow Condition: In order to obtain a correct answer, we must ensure that the result has a sufficient number of bits to
accommodate the sum. If we start with two n‐bit numbers and the sum occupies n + 1 bits, we say that an overflow occurs.
Overflow is indicated by incorrect sign bit.
Overflow is a problem in computers because the number of bits that hold a number is finite, and a result that exceeds the
finite value by 1 cannot be accommodated.

In the above example, the sum 183 requires eight magnitude bits. Since there are seven magnitude bits in the
numbers (and one sign bit), there is a carry into the sign bit which produces the overflow indication.

Other examples-> add: +5 +6, -6 –5


32
Arithmetic Subtraction
Subtraction is a special case of addition. Subtraction of two signed binary numbers in
2’s‐complement form is simple and can be stated as follows:
Rule: Take the 2’s complement of the subtrahend (including the sign bit) and add it to the
minuend (including the sign bit). A carry out of the sign‐bit position is discarded.
This procedure is adopted because a subtraction operation can be changed to an addition operation if
the sign of the subtrahend is changed, as is demonstrated by the following relationship: .

33
Arithmetic Subtraction using 2’s complement
Rule: Take the 2’s complement of the subtrahend (including the sign bit) and add it to the minuend (including the
sign bit). A carry out of the sign‐bit position is discarded.

To see this, consider the subtraction (-6) - (-13) = +7.


The subtraction is changed to addition by taking the 2’s complement of the subtrahend
(-13), giving (+13). 2’s complement representation of -6
2’s complement of +13

Using complement system


✓ Removing the end carry, we obtain the correct answer: 00000111 (+7).

34
Thank you !!!

You might also like