INVITATION TO
Computer Science
Chapter 4
The Building Blocks: Binary Numbers,
Boolean Logic, and Gates

Objectives
After studying this chapter, students will be able to:
•
Translate between base-ten and base-two numbers,
and represent negative numbers using both sign-
magnitude and two’s complement representations
•
Explain how floating-point numbers, character, sounds,
and images are represented inside the computer
•
Build truth tables for Boolean expressions and
determine when they are true or false
•
Describe the relationship between Boolean logic and
computer hardware/circuits
Invitation to Computer Science, 6th Edition
2

Objectives (continued)
After studying this chapter, students will be able to:
•
Construct circuits using the sum-of-products circuit
design algorithm, and analyze simple circuits to
determine their truth tables
•
Explain how the compare-for-equality (CE) circuit works
and its construction from one-bit CE circuits, and do the
same for the adder circuit and its one-bit adder parts
•
Describe the purpose and workings of multiplexor and
decoder control circuits
Invitation to Computer Science, 6th Edition
3

Introduction
•
This chapter is about how computers work
•
Problem: Execute Algorithms on Hardware
=> need value representation, hardware for logic &
arithmetic, program execution
•
All computing devices are built on the ideas in this
chapter
–
Laptops, desktops, Servers, supercomputers
–
Game systems, cell phones, MP3 players
–
Calculators, singing get-well cards
–
Embedded systems, in toys, cars, microwaves, etc.
Invitation to Computer Science, 6th Edition
4

The Binary Numbering System
•
How can an electronic (or magnetic) machine
represent information?
•
Key requirements: clear, unambiguous, reliable
•
External representation is human-oriented
–
base-10 numbers
–
keyboard characters
•
Internal representation is computer-oriented
–
base-2 numbers
–
base-2 codes for characters
–
“bistable” systems are reliable – transistor off/on
Invitation to Computer Science, 6th Edition
5

Invitation to Computer Science, 6th Edition
6

The Binary Numbering System
(continued)
•
The
binary numbering system
is a base-2
positional numbering system
•
Base ten:
–
Uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
–
Each place corresponds to a power of 10
–
1,943 = 1 * 10
3
+ 9 * 10
2
+ 4 * 10
1
+ 3 * 10
0
•
Base two:
–
Uses 2 digits: 0, 1
–
Each place corresponds to a power of 2
–
1101 = 1 * 2
3
+ 1 * 2
2
+ 0 * 2
1
+ 1 * 2
0
= 13
Invitation to Computer Science, 6th Edition
7

8

The Binary Numbering System
(continued)
•
Converting from binary to decimal
–
Add up powers of two where a 1 appears in the
binary number
•
Converting from decimal to binary
–
Repeatedly divide by two and record the remainder
–
Example, convert 9:
•
9/2 = 4 remainder 1, binary number = 1
•
4/2 = 2 remainder 0, binary number = 01
•
2/2 = 1 remainder 0, binary number = 001
•
1/2 = 0 remainder 1, binary number = 1001
Invitation to Computer Science, 6th Edition
9

The Binary Numbering System
(continued)
•