Booleans and Binary logic
tables: class notes
J Warren
What is a boolean?
A boolean is a data type in computer programming and mathematics that can have
one of two values: true or false.
Booleans are used to represent binary or logical states, where true typically
represents a positive or "yes" condition, and false represents a negative or "no"
condition.
Booleans play a fundamental role in decision-making, logic, and conditional
statements in programming, allowing computers to make choices and perform
different actions based on logical conditions.
Booleans in relation to Binary
Booleans and binary numbers are related because both have two possible values.
Booleans represent true and false, while binary numbers use 0 and 1.
Booleans are used for logical operations and conditional statements in
programming, making them a fundamental part of working with binary data and
making decisions based on binary values.
The logic table
A logic table is like a chart that shows how a computer decides whether something
is true or false based on different combinations of 0s and 1s (binary bits).
It lists all the possible combinations of 0s and 1s and tells you what the computer
thinks (true or false) for each combination.
It helps us see how the computer makes decisions using binary input.
Example of the logic table
A simple logic table using a single binary input bit and its corresponding boolean
output:
In this table, when the input bit is 0, the output is False, and when the input bit is 1,
the output is True. This represents a basic logic operation where 0 typically
represents a "no" or "false" condition, and 1 represents a "yes" or "true" condition.
Further examples:
Here are logic tables for four fundamental logic operations: IS, NOT, AND, and
OR, using a single binary input bit (A) and their corresponding boolean outputs on
the following slides
NOTE: In these tables, the outputs are represented as TRUE or FALSE, where
TRUE corresponds to 1, and FALSE corresponds to 0.
EXPLAINER VIDEO: [Link]
IS (Identity) Table:
Think of IS like a mirror.
If you put something in front of the
mirror (0 or 1), it stays the same.
So, if you put 0 in front of the mirror,
it's still 0 (FALSE).
If you put 1 in front of the mirror, it's
still 1 (TRUE).
NOT (Negation) Table:
NOT is like saying the opposite.
If you have 0, NOT 0 means it
becomes 1 (TRUE). If you have 1,
NOT 1 means it becomes 0
(FALSE).
AND (Conjunction) Table:
Think of AND as a meeting where
everyone has to agree for
something to happen.
If one person says no (0), then
the decision is no (FALSE).
Only when everyone says yes (1)
do you get a yes (TRUE).
OR (Disjunction) Table:
OR is like a party where at
least one person needs to say
yes for it to happen.
If anyone says yes (1), then
the party is on (TRUE).
The party is only canceled
(FALSE) if everyone says no
(0).