Lecture
26
Binary Basics
& Review of
Voltages and Currents
1. Review of Fundamentals
of the Number System (not about Python but required for
understanding binary and digital logic)
In
mathematics and digital electronics, a binary number is a number
expressed in the base-2 numeral system or binary numeral system, which
uses only two symbols: typically 0 (zero) and 1 (one).
Base
10 counting system:
We happened to
use the current counting system, because we happened to have ten
fingers.
If dinosaurs had ruled the earth, they would be happy to use a 8-based
counting system..
What does 157 mean? 157 = 1 x 100 + 5 x 10 + 7 x 1 = 1 x 10^2 + 5 x 10^1 + 7 x 10^0
Imagine
a specie that only has two fingers. how can they count? A computer is
such kind of two-finger specie. 0 and 1 Each place is the exponential
of 2.
Base 10: 157: 157 = 1 x 10^2 + 5 x 10^1 + 7 x 10^0
Base 2: 1011 = 1
x 2^3 + 0 x 2^2 + 1 x 2^1 + 1 x 2^0
1 bit is a single bit of information, a 1 or 0. Only two possible
values.
1 byte is 8 bits, an 8 bit word
256 possible values from 0-255 base 10 or 00000000 to 11111111 base 2
10100110 is a single byte
Base 10 to Binary
Binary mathematics
Hexadecimal (base 16):
Binary
code is too long in representation. Hex is much shorter. Converting a
binary number to a Hex number is relatively easy. Every 4 bit can
convert to a Hex.
Problem: we are short of numbers A-10 B-11 C-12 D-13 E-14 F-15
Lookup table:
Example:
2. Review of Electrical
Voltage and Current (This is not about Python but will be
required for programming Raspberry Pi using Python)
We'll go through the examples as follows:
Tasks:
(Show
the calculation process for the credit. Complete these problems on papers)
1.
Convert the following binary numbers to decimal numbers: (1) 1011 (2)
1000 (3)
1111 (4) 1011001 (5) 1000000
2. Convert the following decimal numbers to binary numbers: (1) 10 (2)
8 (3) 16
(4) 52