0% found this document useful (0 votes)
6 views80 pages

Chapter 02

Chapter 2 of 'Digital Fundamentals' covers number systems, including decimal, binary, hexadecimal, and octal, explaining their operations and conversions. It details how computers use binary representation and introduces concepts like signed numbers and Binary Coded Decimal (BCD). The chapter also includes methods for addition, subtraction, and conversions between different number systems.

Uploaded by

kolaybora112
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)
6 views80 pages

Chapter 02

Chapter 2 of 'Digital Fundamentals' covers number systems, including decimal, binary, hexadecimal, and octal, explaining their operations and conversions. It details how computers use binary representation and introduces concepts like signed numbers and Binary Coded Decimal (BCD). The chapter also includes methods for addition, subtraction, and conversions between different number systems.

Uploaded by

kolaybora112
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

Digital Fundamentals

ELEVENTH EDITION
GLOBAL EDITION

CHAPTER 2
Number Systems,
Operations, and
Codes

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-1 Decimal Numbers
• Most people today use decimal representation to count. In the decimal
system there are 10 digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
These digits can represent any value, for example: 754
Important note: any number in power of zero is 1, even zero in power of zero is 1:
The value is formed by the sum of each digit, multiplied by the base (in this case it is 10
because there are 10 digits in decimal system) in power of digit position (counting from
zero):

 Position of each digit is very important! for example if you place "7" to the
end: 547
it will be another value:

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Ex: Express the number 480.52 as the sum of values of each digit.

480.52 = (4 x 102) + (8 x 101) + (0 x 100) + (5 x 10-1) +(2 x 10-2)

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-2 Binary Numbers
• Computers are not as smart as humans are (or not yet), it's easy to make an electronic
machine with two states: on and off, or 1 and 0.
• Computers use binary system, binary system uses 2 digits: And thus the base is 2.
• Each digit in a binary number is called a BIT, 4 bits form a NIBBLE, 8 bits form a
BYTE, two bytes form a WORD, two words form a DOUBLE WORD (rarely used):

 There is a convention to add "b" in the end of a binary number, this way we can
determine that 101b is a binary number with decimal value of 5.
 The binary number 10100101b equals to decimal value of 165:

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
TABLE 2–1

In general, with n
bits you can count
up to a number
equal to 2n-1

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
FIGURE 2-1 Illustration of a simple binary counting application.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
TABLE 2–2 Binary weights.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-3 Converting from Binary to Decimal

Fractional Binary Numbers.


(0.101)2 = ( ? )10
1x2-1 = 0.5
0.5 + 0 + 0.125 = (0.625) 10
0x2-2 =0
1x2-3 = 0.125

Problem: Convert to the binary number 10.111 to decimal.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-4 Converting from Decimal to Binary
Division-by-two method...

(0.125)10 = ( ? )2 (0.625)10 = ( ? )2
0.125x2 = 0.250 0.625x2 = 1.250
(0.001) 2 (0.101) 2
0.250x2 = 0.5
0.250x2 = 0.5
0.5x2 =1
0.5x2 =1
Problem: Convert to the decimal number 139 to binary.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-5 Addition and Subtraction in Binary
Numbers

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Multiplication and Division in Binary Numbers

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Complements of Binary Numbers
Finding the 1’s Complement

1’s complement of a binary number is found by changing all 1s to 0s and all


0s to 1s, as illustrated below.

Binary
Number

1’s
Complement

FIGURE 2-2 Example of inverters used to obtain the 1’s complement of a


binary number.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Complements of Binary Numbers
Finding the 2’s Complement

The 2’s complement of a binary number is found by adding 1 to LSB of the 1’s
complement.
2’s complement = (1’s complement) + 1

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
FIGURE 2-3 Example of obtaining the 2’s complement of a negative binary
number.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Addition and Subtraction in Binary Numbers

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Signed Numbers
• The Sign Bit
The left-most bit in a signed binary number is the sign bit, which tells you
whether the number is positive or negative.
A 0 sign bit indicates a positive number and a 1 sign bit indicates a
negative number.
 For example, the decimal number +25 is expressed as an 8-bit signed
binary number using the sign-magnitude form as

0 0011001

Sign bit Magnitude bits

 The decimal number -25 is expressed as


1 0011001

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Signed Numbers
• There is no way to say for sure whether the hexadecimal byte 0FFh is positive or
negative, it can represent both decimal value "255" and "- 1".
• 8 bits can be used to create 256 combinations (including zero), so we simply presume
that first 128 combinations (0..127) will represent positive numbers and next 128
combinations (128..256) will represent negative numbers.
• In order to get "- 5", we should subtract 5 from the number of combinations (256), so
we'll get: 256 - 5 = 251.
• Using this complex way to represent negative numbers has some meaning, in math
when you add "- 5" to "5" you should get zero.
• This is what happens when processor adds two bytes 5
and 251, the result gets over 255, because of the
overflow processor gets zero!
• When combinations 128..256 are used the high bit is
always 1, so this maybe used to determine the sign of a
number.
• The same principle is used for words (16 bit values), 16
bits create 65536 combinations, first 32768 combinations
(0..32767) are used to represent positive numbers, and
next 32768 combinations (32767..65535) represent
negative numbers.
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Signed Numbers --- 2’s Complement

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal System
• Hexadecimal System uses 16 digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
• And thus the base is 16.
• Hexadecimal numbers are compact and easy to read. It is
very easy to convert numbers from binary system to
hexadecimal system and vice-versa, every nibble (4 bits)
can be converted to a hexadecimal digit using this table:

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
TABLE 2–3

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-8 Hexadecimal System

• There is a convention to add "h" in the end of a hexadecimal


number, this way we can determine that 5Fh is a hexadecimal
number with decimal value of 95.
• We also add "0" (zero) in the beginning of hexadecimal numbers
that begin with a letter (A..F), for example 0E120h.
• The hexadecimal number 1234h is equal to decimal value of 4660:

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Addition and Subtraction in HexNumbers

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Converting from Decimal System to Any Other
• In order to convert from decimal system, to any other system, it is required to
divide the decimal value by the base of the desired system, each time you
should remember the result and keep the remainder, the divide process
continues until the result is zero.
• The remainders are then used to represent a value in that system.
• Let's convert the value of 39 (base 10) to Hexadecimal System (base 16):

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Converting from Decimal System to Any Other
• As you see we got this hexadecimal
number: 27h.
• All remainders were below 10 in the
above example, so we do not use any
letters.
• Here is another more complex
example:
• Let's convert decimal number 43868
to hexadecimal form.
• The result is 0AB5Ch, we are using
the above table to convert remainders
over 9 to corresponding letters.
• Using the same principle we can
convert to binary form (using 2 as the
divider), or convert to hexadecimal
number, and then convert it to binary
number using the above table:
• As you see we got this binary
number: 1010101101011100b

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal Number Systems

• Hexadecimal system is defined to be the


base 16 number system and is used as a
convenient representation of binary
numbers.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal Number Systems

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal Subtraction-Method 1

FIGURE 2-4 Getting the 2’s complement of a hexadecimal number

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal Subtraction

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Hexadecimal Subtraction-Method 2

FIGURE 2-5 Getting the 2’s complement of a hexadecimal number, Method 2.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-9 Octal Numbers

The octal numbers are used less frequently than hexadecimal in conjunction
with computers and microprocessors to express binary quantities for input and
output purposes. The octal number system is composed of eight digits (0..7)

TABLE 2–4 Octal/binary conversion.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Octal Numbers

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-10 Binary Coded Decimal (BCD)
Binary coded decimal (BCD) is a way to express each of the decimal digits with
a binary code.

Convert each of the following decimal numbers to BCD:

a) 3 5 b) 9 8

0011 0101 1001 1000

c) 1 7 0 d) 2 4 6 9

0001 0111 0000 0010 0100 0110 1001

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-10 Binary Coded Decimal (BCD)
BCD Addition:

Step 1: Add the two BCD numbers, using the rules for binary addition.
Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.

Step 3: If a 4-bit sum is greater than 9, or if a carry out of the 4-bit group is
generated, it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip
six invalid states and return the code 8421. If a carry result is added, simply
add carry to the next 4 group.
Examples:
0011 3 1000 0110 86
+ 0100 +4 + 0001 0011 +13
0111 7 1001 1001 99

1001 9
+ 0100 +4
1101 Invalid BCD Number (>9) 13
+ 0110 Add 6
1 0011 13

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-10 Binary Coded Decimal (BCD)
BCD Addition:

Example:

0001 0110 16
+ 0001 0101 + 15
0010 1011 Right group is invalid (>9), left group is valid. 31
+0110 Add 6 to invalid code. Add carry (1) to next group
0011 0001 Valid BCD number (31)

0110 0111 67
+ 0101 0011 + 53
1011 1010 Both groups are invalid (>9) 120
+ 0110 0110 Add 6
1 0010 0000 120

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-11 Digital Codes
Gray Codes
The Gray code is unweighted and is not an arithmetic code; that is, there are
no specific weights assigned to the bit positions. The important feature of the
gray code is that it exhibits only a single bit change from one code word to the
next in sequence.

TABLE 2–6 Four-bit Gray code.


Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Digital Codes
Binary-to-Gray Code Conversion

[Link] most significant bit (left-most) in the Gray code is the same as the
corresponding MSB in the binary number.
[Link] from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit. Discard carries.

Gray-to-Binary Code Conversion

[Link] most significant bit (left-most) in he Gray code is the same as the
corresponding bit in the Gray code.
[Link] each binary code bit generated to the Gray code bit in the next adjacent
position. Discard carries.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
ASCII
It is a universally accepted alphanumeric code used in most computers and other
electronic equipment.

TABLE 2–7 American Standard Code for Information


Interchange (ASCII).

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
2-12 Error Codes

Parity Method for Error Detection

Many systems use a parity bit as a means for


bit error detection. Any group of bits contain
either an even or an odd number of 1s. A
parity bit is attached to a group of bits to
make the total number of 1s in a group always
even or always odd. An even parity bit makes
the total number of 1s even, and an odd parity
bit makes the total odd.

TABLE 2–8 The BCD code


with parity bits.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Error Codes

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Error Codes

Cyclic Redundancy Check (CRC)

The CRC is a widely used code for detecting


one- and two-bit transmission errors when
digital data are transferred on a communication
link.

Modulo-2 Operations
Modulo-2 addition is the same as binary addition
with the carries discarded as shown in Table 2-
9. This particular table describes the modulo-2
operation also known as exclusive-OR and can
be implemented with a logic gate.
•A simple rule for modulo-2 is that the output is
1 if the inputs are different; otherwise, it is 0.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
FIGURE 2-8
The CRC process.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Examples

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
What is the weight of 7 in each of the following numbers?

a.1947 b. 1799 c. 1979

Solution

(a) 1947 = 1x103 + 9x102 + 4x101 + 7x100


= 1x1000 + 9x100 + 4x10 + 7x1
= the weight of 7 here in 100 = 1

(b) 1799 = 1x103 + 7x102 + 9x101 + 9x100


= 1x1000 + 7x100 + 9x10 + 9x1
= the weight of 7 here in 102 = 100

(c) 1979 = 1x103 + 9x102 + 7x101 + 9x100


= 1x1000 + 9x100 + 7x10 + 9x1
= the weight of 7 here in 101 = 10

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Express each of the following decimal numbers as a power of ten.

a.1000 b. 10000000 c. 1000000000

Solution

(a) 1000 = 103


(b) 10000000 = 107
(c) 1000000000 = 109

Example

How high can you count with six decimal digits?

Solution

The highest count is 999999

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert the following binary numbers to decimal

a.001 b. 010 c. 101 d. 110 e. 1010 f. 1011 g. 1110 h. 1111

Solution

(a) 001 = 0x22 + 0x21 + 1x20 = 1


(b) 010 = 0x22 + 1x21 + 0x20 = 2
(c) 101 = 1x22 + 0x21 + 1x20 = 5
(d) 110 =1x22 + 1x21 + 0x20 = 6
(e) 1010 = 1x23 + 0x22 + 1x21 + 0x20 = 10
(f) 1011 = 1x23 + 0x22 + 1x21 + 1x20 = 11
(g) 1110 = 1x23 + 1x22 + 1x21 + 0x20 = 14
(h) 1111 = 1x23 + 1x22 + 1x21 + 1x20 = 15

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert the following binary numbers to decimal

a.100001 b. 100111 c. 101010 d. 111001


e. 1100000 f. 11111101 g. 11110010 h. 11111111

Solution

(a) 100001 = 1x25 + 0x24 + 0x23 + 0x22 + 0x21 + 1x20 = 33


(b) 100111 = 1x25 + 0x24 + 0x23 + 1x22 + 1x21 + 1x20 = 39
(c) 101010 = 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 0x20 = 42
(d) 111001 = 1x25 + 1x24 + 1x23 + 0x22 + 0x21 + 1x20 = 57
(e) 1100000 = 1x26 + 1x25 + 0x24 + 0x23 + 0x22 + 0x21 + 0x20 = 96
(f) 11111101 = 1x27 + 1x26 + 1x25 + 1x24 + 0x23 + 1x22 + 1x21 + 1x20 = 125
(g) 11110010 = 1x27 + 1x26 + 1x25 + 1x24 + 0x23 + 0x22 + 1x21 + 0x20 = 242
(h) 11111111 = 1x27 + 1x26 + 1x25 + 1x24 + 1x23 + 1x22 + 1x21 + 1x20 = 255

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert each binary number to decimal

a.110011.11 b. 101010.01 c. 1000001.111 d. 1111000.101

Solution
(a) 110011.11 = 1  25 + 1  24 + 1  21 + 1  20 + 1  21 + 1  22
= 32 + 16 + 2 + 1 + 0.5 + 0.25 = 51.75
(b) 101010.01 = 1  25 + 1  23 + 1  21 + 1  22 = 32 + 8 + 2 + 0.25
= 42.25
(c) 1000001.111 = 1  26 + 1  20 + 1  21 + 1  22 + 1  23
= 64 + 1 + 0.5 + 0.25 + 0.125 = 65.875
(d) 1111000.101 = 1  26 + 1  25 + 1  24 + 1  23 + 1  21 + 1  23
= 64 + 32 + 16 + 8 + 0.5 + 0.125 = 120.625

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
What is the highest decimal number that can be represented by each of the
following numbers of binary digits (bits)?

[Link], three, ….., ten, eleven.

Solution
(a) 22  1 = 3 (11)2 (b) 23  1 = 7
(c) 24  1 = 15 (1111)2 (d) 25  1 = 31
(e) 26  1 = 63 (f) 27  1 = 127
(g) 28  1 = 255 (h) 29  1 = 511
(i) 210  1 = 1023 (j) 211  1 = 2047

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
How many bits are required to represent the following decimal numbers?

a.5 b. 10 c. 15 d. 20 e. 100 f. 120 g. 140 h. 160

Solution

(a) (22-1) < 5 < (23-1) = 3 bits


(b) (23-1) < 10 < (24-1) = 4 bits
(c) (23-1) < 15 = (24-1) = 4 bits
(d) (24-1) < 20 < (25-1) = 5 bits
(e) (26-1) < 100 < (27-1) = 7 bits
(f) (26-1) < 120 < (27-1) = 7 bits
(g) (27-1) < 140 < (28-1) = 8 bits
(h) (27-1) < 160 < (28-1) = 8 bits

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert each decimal number to binary by using the sum-of-weights method.

a.12 b. 15 c. 25 d. 50 e. 65 f. 97 g. 127 h. 198

Solution

(a) 12 = 8 + 4 = 23 + 22 = 1000 + 100 = 1100


(b) 15 = 8 + 4 + 2 + 1 = 23 + 22 + 21 + 1 = 1000 + 100 + 10 + 1 = 1111
(c) 25 = 16 + 8 + 1 = 24 + 23 + 1 = 10000 + 1000 + 1 = 11001
(d) 50 = 32 + 16 + 2 = 25 + 24 + 21 = 100000 + 10000 + 10 = 110010
(e) 65 = 64 + 1 = 26 + 20 = 1000000 + 1 = 1000001
(f) 97 = 64 + 32 + 1 = 26 + 25 + 20 = 1000000 + 100000 + 1 = 1100001
(g) 127 = 64 + 32 + 16 + 8 + 4 + 2 + 1 = 26 + 25 + 24 + 23 + 22 + 21
+ 20 = 1111111
(h) 198 = 128 + 64 + 4 + 2 = 27 + 26 + 22 + 21 = 11000110

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert each decimal fraction to binary using repeated multiplication by 2.

a.0.76 b. 0.456 c. 0.8732

Solution
(a) 0.76  2 = 1.52 1 (MSB) (b) 0.456  2 = 0.912 0 (MSB)
0.52  2 = 1.04 1 0.912  2 = 1.824 1
0.04  2 = 0.08 0 0.824  2 = 0.648 1
0.08  2 = 0.16 0 0.648  2 = 1.296 1
0.16  2 = 0.32 0 0.296  2 = 0.592 0
0.32  2 = 0.64 0 continue if more accuracy is desired
continue if more accuracy is desired 0.01110
0.110000

(c) 0.8732  2 = 1.7462 1 (MSB)


0.7462  2 = 1.4924 1
0.4924  2 = 0.9848 0
0.9848  2 = 1.9696 1
0.9696  2 = 1.9392 1
continue if more accuracy is desired
0.11011

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Add the binary numbers

a.10 + 10 b. 10 + 11 c. 100 + 11

d. 111 + 10 e. 1111 + 111 f. 1111 + 1111

Solution

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Use direct subtraction on the following binary numbers:

a.10 - 1 b. 100 - 11 c. 110 - 100

d. 1111 - 11 e. 1101 – 101 f. 110000 - 1111

Solution

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Perform the following binary multiplications:

a.11 × 10 b. 101 × 11 c. 111 × 110

d. 1100 × 101 e. 1110 × 1110 f. 1111 × 1100

Solution

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Determine the 1’s complement of each binary number:

a.100 b. 111 c. 1100

d. 10111011 e. 1001010 f. 10101010

Solution
(a) The 1’s complement of 100 is 011.
(b) The 1’s complement of 111 is 000.
(c) The 1’s complement of 1100 is 0011.
(d) The 1’s complement of 10111011 is 01000100.
(e) The 1’s complement of 1001010 is 0110101.
(f) The 1’s complement of 10101010 is 01010101

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Determine the 2’s complement of each binary number:

a.11 b. 110 c. 1010 d. 1001

e. 101010 f. 11001 g. 11001100 h. 11000111

Solution

Take the 1’s complement and add 1:

(a) 00 + 1 = 01 (b) 001 + 1 = 010


(c) 0101 + 1 = 110 (d) 0110 + 1 = 0111
(e) 010101 + 1 = 10110 (f) 00110 + 1 = 00111
(g) 00110011 + 1 = 110100 (h) 00111000 + 1 = 0011001

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example

Express each decimal number in binary as an 8-bit sign-magnitude number:

a.+29 b. -85 c. + 100 d. -123

Solution

(a) Magnitude of 29 = 0011101 (b) Magnitude of 85 = 1010101


+ 29 = 00011101 85 = 11010101

(c) Magnitude of 10010 = 1100100 (d) Magnitude of 123 = 1111011


+100 = 01100100 123 = 11111011

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Express each decimal number in binary as an 8-bit number in the 2’s
complement form:

a.+12 b. -68 c. +101 d. -125

Solution

(a) Magnitude of 12 = 1100 (b) Magnitude of 68 = 1000100


+12 = 00001100 68 = 10111100

(c) Magnitude of 10110 = 1100101 (d) Magnitude of 125 = 1111101


+10110 = 01100101 125 = 10000011

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Determine the decimal value of each signed binary number in the sign-
magnitude form:

a.10011001 b. 01110100 c. 10111111

Solution

(a) 10011001 = 25


(b) 01110100 = +116
(c) 10111111 = 63

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Determine the decimal value of each signed binary number in the 2’s
complement form:

a.10011001 b. 01110100 c. 10111111

Solution
(a) 10011001 = (1100111) = 103
(b) 01110100 = +(1110100) = +116
(c) 10111111 = (1000001) = 65

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example
Convert each hexadecimal number to binary:

a.4616 b. 5416 c. B416 d. 1A316

e. FA16 f. ABC16 g. ABCD16

Solution

(a) 4616 = 100 0110


(b) 5416 = 101 0100
(c) B416 = 1011 0100
(d) 1A316 = 1 1010 0011
(e) FA16 = 1111 1010
(f) ABC16 = 1010 1011 1100
(g) ABCD16 = 1010 1011 1100 1101

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:
Convert each binary number to hexadecimal:

a.1111 b. 1011 c. 11111 d. 10101010

e. 10101100 f. 10111011

Solution:

(a) 1111 = F16


(b) 1011 = B16
(c) 11111 = 1F16
(d) 1010 1010 = AA16
(e) 10101100= AC16
(f) 10111011 = BB16

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:
Convert each hexadecimal number to decimal:

a.4216 b. 6416 c. 2B16 d. 4D16

e. FF16 f. BC16 g. 6F116 h. ABC16

Solution:

(a) 42 = 4  161 + 2  160 = 64 + 2 = 66


(b) 64 = 6  161 + 4  160 = 96 + 4 = 100
(c) 2B = 2  161 + 11  160 = 32 + 11 = 43
(d) 4D = 4  161 + 13  160 = 64 + 13 = 77
(e) FF = 15  161 + 15  160 = 240 + 15 = 255
(f) BC = 11  161 + 12  160 = 176 + 12 = 188
(g) 6F1 = 6 162 + 15  161 + 1  160 = 1536 + 240 + 1 = 1777
(h) ABC = 10 162 + 11  161 + 12  160 = 2560 + 176 + 12 = 2748

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Perform the following subtractions:

a.6016 - 3916 b. A516 - 9816 c. F116 – A616 d. AC16 - 1016

Solution:

(a) 6016  3916 = 2716


(b) A516  9816 = D16
(c) F116  A616 = 4B16
(d) AC16  1016 = 9C16

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Convert each octal number to decimal:

a.148 b. 538 c. 678 d. 1748

e. 6358 f. 2548 g. 26738 h. 77778

Solution:

(a) 148 = 1  81 + 4  80 = 8 + 4 = 12
(b) 538 = 5  81 + 3  80 = 40 + 3 = 43
(c) 678 = 6  81 + 7  80 = 48 + 7 = 55
(d) 1748 = 1  82 + 7  81 + 4  80 = 64 + 56 + 4 = 124
(e) 6358 = 6  82 + 3  81 + 5  80 = 384 + 24 + 5 = 413
(f) 2548 = 2  82 + 5  81 + 4  80 = 128 + 40 + 4 = 172
(g) 26738 = 2  83 + 6  82 + 7  81 + 3  80 = 1024 + 384 + 56 + 3 = 1467
(h) 77778 = 7  83 + 7  82 + 7  81 + 7  80 = 3584 + 448 + 56 + 7 = 4095

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Convert each binary number to octal:

a.100 b. 110 c. 1100 d. 1111 e. 11001

f. 11110 g. 110011 h. 101010 i. 10101111

Solution:
(a) 100 = 48
(b) 110 = 68
(c) 1100 = 148
(d) 1111 = 178
(e) 11001 = 318
(f) 11110 = 368
(g) 110011 = 638
(h) 101010 = 528
(i) 10101111 = 2578
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Convert each of the following decimal number to 8421 BCD:

a.10 b. 13 c. 18 d. 21 e. 125 f. 156

Solution:

(a) 10 = 0001 0000


(b) 13 = 0001 0011
(c) 18 = 0001 1000
(d) 21 = 0010 0001
(e) 125 = 0001 0010 0101
(f) 156 = 0001 0101 0110

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:
Convert each of the BCD numbers to decimal:

a.00011000 b. 00011001 c. 00110010

d. 01000101 e. 10011000 f. 100001110000

Solution:

(a) 0001 1000 = 18


(b) 0001 1001 = 19
(c) 0011 0010 = 32
(d) 0100 0101 = 45
(e) 1001 1000 = 98
(f) 1000 0111 0000 = 870

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:
Add the following BCD numbers:

a.0010 0101 + 0010 0111 b. 0101 0001 + 0101 1000

c. 1001 1000 + 1001 0111 d. 0101 0110 0001 + 0111 0000 1000

Solution:

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Convert each binary numbers to Gray code:

a.11011 b. 1001010 c. 1111011101110

Solution:

(a) 1 + 1 + 0 + 1 + 1 Binary (b) 1 + 0 + 0 + 1 + 0 + 1 + 0 Binary


1 0 1 1 0 Gray 1 1 0 1 1 1 1 Gray

(c) 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 0 Binary
1 0 0 0 1 1 0 0 1 1 0 0 1 Gray

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Convert each Gray code to binary:

a.1010 b. 00010 c. 11000010001

Solution:

(a) 1 0 1 0 Gray (b) 0 0 0 1 0 Gray


1 1 0 0 Binary 0 0 0 1 1 Binary

(c) 1 1 0 0 0 0 1 0 0 0 1 Gray
1 0 0 0 0 0 1 1 1 1 0 Binary

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Determine the ASCII character:

a.0111101 b. 0100011 c. 0111110 d. 1000010

Solution:

(a) 0111101  = (b) 0100011  #


(c) 0111110  > (d) 1000010  B

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Determine which of the following even parity codes are in error:

a.100110010 b. 011101010 c. 10111111010001010

Solution:

Reminding: An even parity bit makes the total number of 1s even,


and an odd parity bit makes the total odd.

Code (b) 011101010 has five 1s, so it is in error.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Determine which of the following odd parity codes are in error:

a.11110110 b. 00110001 c. 01010101010101010

Solution:

Reminding: An even parity bit makes the total number of 1s even,


and an odd parity bit makes the total odd.

Codes (a) 11110110 and (c) 01010101010101010 are in error


because they have an even number of 1s.

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Example:

Attach the proper even parity bit to each of the following bytes of data:

a.10100100 b. 00001001 c. 11111110

Solution:

Reminding: An even parity bit makes the total number of 1s even,


and an odd parity bit makes the total odd.

(a) 1 10100100
(b) 0 00001001
(c) 1 11111110

Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved
Digital Fundamentals, Eleventh Edition, Global Edition Copyright © 2016 by Pearson Education, Ltd.
Thomas L. Floyd All Rights Reserved

You might also like