Sunteți pe pagina 1din 14

Course: Electronics – for Complete Beginners

Section 8: Monolithic Integrated Circuits


Lecture 4: Binary Number Systems

Learning to Count
Before we begin making a big deal over
binary numbers, let’s remember Bob
Widlar’s famous utterance, “Any idiot can
count up to one!”
---
Widlar’s world was analog circuits, which
could deal with continuously variable data,
and was quite compatible with decimal
numbers and arithmetic functions. Digital
electronics, on the other hand, is inherently
binary — on/off, high/low, saturation or cut-
off. There is such a thing as analog
computers, but digital computers have
overwhelmingly won the day by virtue of
their low cost, high speed, and precision
accuracy.
The is nothing really mysterious or
wonderful about the binary number system.
The truth is that it is quite useless … except
for the fact that in digital electronics there
are two discrete states, which quite naturally
came to be equated with zeroes and ones.
In many cases, the expressions have no
actual numerical value, but merely represent
the state of any input or output; “high” and
“low” being represented as “logical 1” and
“logical 0”.
In other cases, binary numbers are used as
codes representing various alpha-numeric
characters and special symbols.
In still other cases, they may represent an
address, perhaps in a local memory system,
a hard drive, or of a location somewhere out
on the Internet.
Finally, binary numbers are used for
arithmetic operations, usually with user-
friendly decimal numbers converted to their
binary equivalent, and the binary result of
the operation converted to decimal, because
that’s what our minds have been trained to
work with.
Widlar was actually quit right; counting in
binary is a skill that any simpleton would
ordinarily be able to acquire quite easily. It
only seems complex sometimes, because it
is such an unwieldy system.
---
To ward off some of the seeming
complexity, let’s briefly look at the decimal
number system that we’re all so familiar
with and skillful in using. Unless you’re a
mathematician, it might have never occurred
to you that the decimal number system is
actually built on powers of ten …
1 = 100
10 = 101
100 = 102
1,000 = 103, and so on.
Likewise …
0.1 = 10-1
0.01 = 10-2
0.001 = 10-3, and so on.
The decimal counting system consists of
ten digits, named “0” through “9”. Counting
is a process of ticking through this set of
available digits in an orderly way until
reaching the last available one, “9”, then
incrementing the next higher decade by one,
and then rolling over to begin again in the
first decade with “0”.
It’s a ripple-counting process, with that
operation going on within each decade even
though the actual counting operation is
happening in the first one, such that when
the total happens to be “9”, the next count
causes a rollover to “10” … or if it happens
to be “99999”, the next count causes a
rollover in each decade, producing a total of
“100000”.
By convention, the least significant decade
is always on the right, with the count
accumulating to the left. For convenience in
interpreting large totals, we arrange the
decades in threes using a comma as a
separator. Hence in the number “5,002” the
“5” represents thousands (or 5 x103) and the
“2” represents ones (or 2 x 100).
The Binary Number System
The binary number system operates in the
same way. The only difference is that
instead of having ten digits available, there
are only two, and they are arbitrarily
designated as “0” and “1”.
The binary counting system therefore
operates on powers of two …
0001 = 20
0010 = 21
0100 = 22
1000 = 23, and so on.
Likewise …
000.1 = 2-1
00.01 = 2-2
0.001 = 2-3, and so on.
The leading zeros … in”0001” for
example … have been included here to
signify that these are binary values, not
decimal values. For example, the binary
value “1000” is the binary equivalent of the
decimal value “8” (or 1 x 23), not decimal
one-thousand.
Counting in binary is the same as counting
with decimal numbers, except for the fact
that there are only two digits. So you count
from “0” to “1” in the 20 position, and then
on the next count, that position becomes “0”
again, with a “1” carried left into the 21
position.
This is the same sort of process as
counting from “0” to “9” in the 100 position
of the decimal system, and then having that
position rollover back to “0” while carrying
a “1” into the next position at the left, the
101 position.
Notice the simple intuitive pattern of the
binary counting process …
00002 = 01
00012 = 110
00102 = 210
00112 = 310
01002 = 410
01012 = 510

10102 = 1010
10112 = 1110
11002 = 1210
11012 = 1310
11102 = 1410
11112 = 1510
When converting from binary to decimal,
or vice versa, rather than thinking in powers
of two, it’s usually easier to just remember
the sequence of decimal values representing
each higher position in the binary count …
0 0 0 0 0 0 0 0
128 64 32 16 8 4 2 1
… the decimal value doubling in each
higher position.
This makes it easy to decipher a binary
number. Just tally up the decimal values for
each position containing a “1” …
e.g., “1101 01102” = ?10
1 1 0 1 0 1 1 0
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
128 64 32 16 8 4 2 1
= 21410
Notice how the “2” and “10” subscripts can
be used to eliminate any ambiguity as to
which number system we’re talking about
when working with mixed numbers.
In the same way, it’s easy to convert a
decimal number to its binary equivalent. Just
begin at the left by subtracting the highest
decimal equivalent value that is not larger
than the decimal number itself, and mark
that binary position as “1”. Then find the
next lower decimal equivalent value that is
not larger than the remainder, and mark that
position as “1”, repeating the process until
the remainder is zero. Then mark the blank
binary positions as “0”.
e.g., 11810 = ?2
128 64 32 16 8 4 2 1
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
0 1 1 1 0 1 1 0 = 0111 01102
Each binary digit is called a bit. To make
binary numbers easier to read, they’re
usually split into space-separated sets of four
digits.
Notice how the least significant four bits
can express a total of sixteen possible
values, from “010” to “1510”. The least
significant eight bits can express a total of
256 values, from 010 to 25510. This set of
eight bits is called a byte.
That convention originated from the fact
that early computers used eight bits to
encode alpha-numeric characters, and for
that reason the byte became the smallest
addressable unit of computer memory.
It’s possible, of course, to do all the usual
mathematical operations with binary
numbers — addition, subtraction,
multiplication, division, and so on — and
the process isn’t much different than you
already know how to do with decimal
numbers. If you decide to get into computer
programming, you’ll probably need to
become proficient in binary math. For our
purposes, it isn’t essential, so we won’t be
spending any time on that.
The BCD System
At this point in our discussion, let’s
remember that mankind has used the Hindu-
Arabic number system (a.k.a., the decimal
system) for over 2,000-years. Were it not for
the two-state nature of logic circuitry, you
probably would have never heard of the
binary number system. Until someone
invents ten-state logic, we’ll be stuck with
this unwieldy necessity.
One way of making binary numbers
conform to our way of thinking is a scheme
called binary-coded decimal, or BCD. In this
system, 4-bit binary codes are used to
represent the decimal numerals “0” through
“9” and the decimal decades … ones, tens,
hundreds, thousands, and so on.
Here’s an example …
106410 = 0001 0000 0110 0100BDC
The 4-bit patterns, sometimes called
nibbles or half-bytes, have the limited range
of from “0000” to “1001” … “0” to “9” in
other words. Values higher than “1001”
(“1010” to “1111”) are illegal codes which
have no meaning in BCD.
Eight-bit bytes may be used to carry two
BCD numbers, in which case the technique
is called packed BCD.
For example, “1001 0110BCD” would be a
“910” and a “610”, and not 15010.
Unpacked BCD uses a whole byte for each
decimal number, with only the four least-
significant bits being meaningful, and the
remaining bits having no significance.
BCD is used mainly in connection with the
human-readable display of alphanumeric
data, especially as inputs to chips that
control seven-segment displays, usually
called BCD/7-Segment Decoder/Drivers.
Hexadecimal
Just when you thought you were getting
the hang of it …
Since four-bit nibbles can represent
sixteen decimal values — from “0” to “15”
— another “quasi-decimal” number system
was devised; one that adds six more digits to
the standard decimal set of ten …
0123456789ABCDEF
… “Ah” representing “1010” and Fh
representing 1510.
This is called hexadecimal, or often just
plain hex. Notice the use of the subscript “h”
to identify the number as a hexadecimal
value.
This is a base-16 system, meaning that it’s
based on powers of 16 …
0000 0000 0000 0001h = 160 = 110
0000 0000 0001 0000h = 161 = 1610
0000 0001 0000 0000h = 162 = 25610
0001 0000 0000 0000h = 163 = 4,09610
…etc.
You’ll notice that so far, this doesn’t look
any different than regular binary numbers.
Hex is really more like a shorthand for
writing binary values …
Each hex digit represents a four-bit binary
value. If you were to see a value expressed
as “5Eh”, the “5” represents “0101” and the
“E” represents “1110”, or “0101 11102”
which equates to 9410.
Sometimes values expressed in hex are
identified by the prefix “0x”, for example
“0x5E”. (This is a relic of early program
compilers, where the “0” signaled that the
value was a constant, and the “x” identified
the number’s base as hexadecimal.)
As a final exercise, see if you can find the
decimal equivalent of “FACEh”.
---
The four-bit binary nibbles would be …
1111 1010 1100 1110
… so the decimal equivalent would be ...
64,20610.
---
Binary number systems are not ordinarily
an important part of basic electronics, but
the subject does become relevant in
connection with complex digital devices —
which is the subject of our next lecture.
---

S-ar putea să vă placă și