After finishing this chapter, you should be able to:
Provide a brief definition of each the following terms: American Standard Code for
Information Interchange (ASCII), AND, Boolean algebra, Boolean function, Boolean
logic, collate, collating sequence, logical comparison operators, NOT, OR, proximity
function, and Unicode
Describe the function of the Boolean operations AND, OR, and NOT, and show how
they are used in Alice branching and looping instructions
List and describe the function of the six logical comparison operators, and show how
they are used to form Boolean conditions in Alice
Describe what a Boolean function is and how such functions are used in Alice
Create new methods in Alice that use Boolean conditions involving random numbers,
Boolean functions, and method parameters
BOOLEAN LOGIC IN
PROGRAMMING
1
5
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
2
Chapter 5 • Boolean Logic in Programming
BOOLEAN LOGIC
Branching and looping routines both contain conditions that are either true or false. In
1854, George Boole, the first Professor of Mathematics at Queen’s College in Cork, Ireland,
published a book titled “
An investigation into the Laws of Thought, on which are founded
the Mathematical Theories of Logic and Probabilities.”
Boole outlined a system of logic and
a corresponding algebraic language dealing with true and false values. Today that type of
logic is called
Boolean logic,
and his language is called
Boolean algebra
. The conditions
that exist in branching and looping routines are a form of Boolean logic.
Boolean Logic is the basis for all modern digital electronic technology. The
howstuffworks.com Website has an article about how computers implement Boolean logic at
http://computer.howstuffworks.com/boolean.htm
. In 1858 Boole’s original book was repub
lished as “An Investigation of the Laws of Thought”. Copies of the 1973 reprint of this edition
can still be found in many bookstores and online. The complete text of an 1848 paper by Boole
titled the
Calculus of Logic
, is available on the Web at:
http://www.maths.tcd.ie/pub/HistMath/
People/Boole/CalcLogic
. The site is maintained by the University of Dublin’s Trinity College
School of Mathematics. They also maintain links to information about George Boole at
http://www.maths.tcd.ie/pub/HistMath/People/Boole
.
Boolean logic is a form of mathematics in which the only values used are true and false.
There are three basic operations in Boolean logic – AND, OR, and NOT, as described in
Figure 51.
The AND and OR operations are binary operations, meaning that they need two operands.
Basically, when two values are combined in the
AND
operation, the result is true only if
both values are true. Otherwise, the result is false. In the
OR
operation, if either value is
true, then the result is true.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 Alice
 Boolean Algebra

Click to edit the document details