Binary Numbers and Computer Speed

Posted by PITHOCRATES - April 2nd, 2014

Technology 101

Computers are Good at Arithmetic thanks to Binary Numbers

Let’s do a fun little experiment.  Get a piece of paper and a pen or a pencil.  And then using long division divide 4,851 by 34.  Time yourself.  See how long it takes to complete this.  If the result is not a whole number take it to at least three places past the decimal point.  Okay?  Ready……..start.

Chances are the older you are the faster you did this.  Because once upon a time you had to do long division in school.  In that ancient era before calculators.  Younger people may have struggled with this.  Because the result is not a whole number.  Few probably could do this in their head.  Most probably had a lot of scribbling on that piece of paper before they could get 3 places past the decimal point.  The answer to three places past the decimal point, by the way, is 142.676.  Did you get it right?  And, if so, how long did it take?

Probably tens of seconds.  Or minutes.  A computer, on the other hand, could crunch that out faster than you could punch the buttons on a calculator.  Because one thing computers are good at is arithmetic.  Thanks to binary numbers.  The language of all computers.  1s and 0s to most of us.  But two different states to a computer.  That make information the computer can understand and process.  Fast.

A Computer can look at Long Streams of 1s and 0s and make Perfect Sense out of Them

The numbers we use in everyday life are from the decimal numeral system.  Or base ten.  For example, the number ‘4851’ contains four digits.  Where each digit can be one of 10 values (0, 1, 2, 3…9).   And then the ‘base’ part comes in.  We say base ten because each digit is a multiple of 10 to the power of n.  Where n=0, 1, 2, 3….  So 4851 is the sum of (4 X 103) + (8 X 102) + (5 X 101) + (1 X 100).  Or (4 X 1000) + (8 X 100) + (5 X 10) + (1 X 1).  Or 4000 + 800 + 50 + 1.  Which adds up to 4851.

But the decimal numeral system isn’t the only numeral system.  You can do this with any base number.  Such as 16.  What we call hexadecimal.  Which uses 16 distinct values (0, 1, 2, 3…9, A, B, C, D, E, and F).  So 4851 is the sum of (1 X 163) + (2 X 162) + (15 X 161) + (3 X 160).  Or (1 X 4096) + (2 X 256) + (15 X 16) + (3 X 1).  Or 4096 + 512 + 240 + 3.  Which adds up to 4851.  Or 12F3 in hexadecimal.  Where F=15.  So ‘4851’ requires four positions in decimal.  And four positions in hexadecimal.  Interesting.  But not very useful.  As 12F3 isn’t a number we can do much with in long division.  Or even on a calculator.

Let’s do this one more time.  And use 2 for the base.  What we call binary.  Which uses 2 distinct values (0 and 1).  So 4851 is the sum of (1 X 212) + (0 X 211) + (0 X 210) + (1 X 29) + (0 X 28) + (1 X 27) + (1 X 26) + (1 X 25) + (1 X 24) + (0 X 23) + (0 X 22) + (1 X 21) + (1 X 20).  Or (1 X 4096) + (0 X 2048) + (0 X 1024) + (1 X 512) + (0 X 256) + (1 X 128) + (1 X 64) + (1 X 32) + (1 X 16) + (0 X 8) + (0 X 4) + (1 X 2) + (1 X 1).  Or 4096 + 0 + 0 + 512 + 0 + 128 + 64 + 32 + 16 + 0 + 0 + 2 + 1.  Which adds up to 4851.  Or 1001011110011 in binary.  Which is gibberish to most humans.  And a little too cumbersome for long division.  Unless you’re a computer.  They love binary numbers.  And can look at long streams of these 1s and 0s and make perfect sense out of them.

A Computer can divide two Numbers in a few One-Billionths of a Second

A computer doesn’t see 1s and 0s.  They see two different states.  A high voltage and a low voltage.  An open switch and a closed switch.  An on and off.  Because of this machines that use binary numbers can be extremely simple.  Computers process bits of information.  Where each bit can be only one of two things (1 or 0, high or low, open or closed, on or off, etc.).  Greatly simplifying the electronic hardware that holds these bits.  If computers processed decimal numbers, however, just imagine the complexity that would require.

If working with decimal numbers a computer would need to work with, say, 10 different voltage levels.  Requiring the ability to produce 10 discrete voltage levels.  And the ability to detect 10 different voltage levels.  Greatly increasing the circuitry for each digit.  Requiring far more power consumption.  And producing far more damaging heat that requires more cooling capacity.  As well as adding more circuitry that can break down.  So keeping computers simple makes them cost less and more reliable.  And if each bit requires less circuitry you can add a lot more bits when using binary numbers than you can when using decimal numbers.  Allowing bigger and more powerful number crunching ability.

Computers load and process data in bytes.  Where a byte has 8 bits.  Which makes hexadecimal so useful.  If you have 2 bytes of data you can break it down into 4 groups of 4 bits.  Or nibbles.  Each nibble is a 4-bit binary number that can be easily converted into a single hexadecimal number.  In our example the binary number 0001 0010 1111 0011 easily converts to 12F3 where the first nibble (0001) converts to hexadecimal 1.  The second nibble (0010) converts to hexadecimal 2.  The third nibble (1111) converts to hexadecimal F.  And the fourth nibble (0011) converts to hexadecimal 3.  Making the man-machine interface a lot simpler.  And making our number crunching easier.

The simplest binary arithmetic operation is addition.  And it happens virtually instantaneously at the bit level.  We call the electronics that make this happen logical gates.  A typical logical gate has two inputs.  Each input can be one of two states (high voltage or low voltage, etc.).  Each possible combination of inputs produces a unique output (high voltage or low voltage, etc.).  If you change one of the inputs the output changes.  Computers have vast arrays of these logical gates that can process many bytes of data at a time.  All you need is a ‘pulsing’ clock to sequentially apply these inputs.  With the outputs providing an input for the next logical operation on the next pulse of the clock.

The faster the clock speed the faster the computer can crunch numbers.  We once measured clock speeds in megahertz (1 megahertz is one million pulses per second).  Now the faster CPUs are in gigahertz (1 gigahertz is 1 billion pulses per second).  Because of this incredible speed a computer can divide two numbers to many places past the decimal point in a few one-billionths of a second.  And be correct.  While it takes us tens of seconds.  Or even minutes.  And our answer could very well be wrong.


Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Sound Waves, Phonograph, Stylus, Piezoelectric & Magnetic Cartridges, Thermionic Emission, Vacuum Tube, PN-Junction, Transistor and Amplifier

Posted by PITHOCRATES - May 2nd, 2012

Technology 101

The First Phonographs used a Stylus attached to a Diaphragm to Vibrate the Air and a Horn for Amplification 

Sound is vibration.  Sound waves we hear are vibrations in the air.  A plucked guitar string vibrates.  It transfers that vibration to the soundboard on the guitar body.  The vibration of the soundboard vibrates the air inside the guitar body.  Amplifying it.  And shaping it.  Giving it a rich and resonant sound.  Creating music.  And we can reverse this process.  Taking these vibrations from the air.  And putting them into a piece of wax.  Via a vibrating needle.  Or stylus.  Cutting wavy grooves into wax.  And then we can even reverse this process.  By dragging a stylus through those same wavy groves.  Causing the stylus to vibrate.  And if we transfer those vibrations to the air we can hear those sound waves.  And listen to the music they make.

The first phonographs could reproduce sound.  But they didn’t sound very good.  The first phonographs were purely mechanical.  A stylus vibrated a diaphragm.  The diaphragm vibrated the air.  And a horn attached to that diaphragm was the only amplification.  Sort of like cupping your hands around your mouth when shouting.  Which reinforced and concentrated the sound waves.  Making them louder in the direction you were facing.  Which is how these early phonographs worked.  But the quality of the sound was terrible.  And played at only one volume.  Low.

Electric circuits changed the way we listen to music.  Because we could amplify those low volumes.  By changing the vibrations created from those wavy grooves into an electrical signal.  The first phonographs used a piezoelectric cartridge.  Which the stylus attached to.  The piezoelectric cartridge converted a mechanical pressure (the needle vibrating in the wavy groove) into electricity.  Later phonographs used a magnetic cartridge.  Which did the same thing only using a varying magnetic field.  The vibration of the needle moved a magnet or a coil through a magnetic field.  Thus inducing a current in a coil.  Then all you needed was an amplifier and a loudspeaker to make sweet music.

Small Changes in the Control Grid Voltage of a Vacuum Tube make Larger Changes in the Plate Voltage

The first amplifiers used vacuum tubes.  Things that once filled our televisions and stereo systems.  Back in the old days.  Up until about the Seventies.  A vacuum tube operated on the principle of thermionic emission.  Which basically means if you heat a metal filament it will ‘boil off’ electrons.  The basic vacuum tube used for amplification consisted of a cathode and an anode.  Or filament and plate.  And a control grid in between.  Sealed in, of course, a vacuum.  Creating the triode.  The cathode (filament) and anode (plate) created an electric field when connected to a large power source.  The cathode is negative.  And the anode is positive.  When negatively charged electrons are ‘boiled off’ of the cathode the positive anode attracts them.  The greater the heat the greater the thermionic emission.  And the greater the current flow from cathode to anode.  Unless we change the electric field to inhibit the flow of current.  Which is the purpose of the control grid.

Small changes in the control grid voltage will make changes in the large current flowing from cathode to anode.  That is, the larger current replicates the smaller signal applied to the control grid.  This allows the triode to take the low voltage from a phonograph cartridge and amplify it to a higher voltage with enough power to drive a loudspeaker.  Which is similar to diaphragm and horn on the first phonographs.  Only the amplified electric signal moves a lot more air.  And better materials and construction create a better quality sound.  Amplifiers with vacuum tubes make beautiful music.  High-end audio equipment still uses them to this day.  Including almost all electric guitar amps.  So if they have the highest quality why don’t we use them elsewhere?  Because of thermionic emission.  And the heat required to ‘boil off’ those electrons.

Vacuum tubes worked well when plugged into line power.  Such as a radio in a house.  But they don’t work well on batteries.  Because it takes a lot of electric power to heat those filaments.  And you need pretty big batteries to get that kind of electric power.  Like a car battery.  But even a car battery didn’t let you listen to music for long when parked with the engine off.  Because those tubes drained that battery pretty fast.  So there were limitations in using vacuum tubes.  They draw a lot of power.  Produce a lot of heat.  And tend to be pieces of furniture in your house because of their physical size.

Small Changes in the Base Current of a Transistor is Replicated in the Larger Collector-Emitter Current

The transistor changed that.  Making music more portable.  Thanks to semiconductors.  Material with special electric properties.  Based on the amount of electrons in the atoms making up this material.  Atoms with extra electrons make material with a negative charge (N-material).  Atoms missing some electrons make material with a positive charge (P-material).  When you put these materials together the N and the P attract each other.  Electrons cross the junction and fill in the holes that were missing electrons.  And the ‘holes’ cross the junction and fill in the spaces where there were excess electrons.  (When an electron moved, say, from right to left it made a hole and filled a hole.  It made a hole where it once was.  And it filled a hole where it now is.  So it looks like the hole moved from left to right when the electron moved from right to left.)  Neutralizing the N-material and the P-material.  But creating a charged region around the junction.  And it’s this electron flow and hole flow that make these PN junctions work.  When you add a third material you get a transistor.  Made up of three parts (NPN or PNP).  Emitter, base, and collector.

To get the electrons and holes flowing you start applying voltages across the junctions.  A large current will flow from the collector to the emitter.  Similar to the current flow in a tube from cathode to anode.  And a small base current will change that current flow.  Just like the control grid in a vacuum tube.  Small changes in the base current will make similar changes in the larger collector-emitter current.  Just like in a vacuum tube, the larger current replicates the smaller signal applied to the ‘control’.  Or base.  This allows the transistor to take the low-level signal from a phonograph cartridge and amplify it to a higher level.  Just like a vacuum tube.  Only with a fraction of the electric power.  Because there are no filaments to heat. 

Low power consumption and the small physical size allowed much smaller amplifiers.  And amplifiers that everyday batteries could power.  Creating new ways to listen to music.  From the pocket-size transistor radio.  To the bigger stereo boombox.  To the iPod.  Where the basic principle of how we listen to music hasn’t changed.  Just how we vibrate the air that makes that music has.


Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

FUNDAMENTAL TRUTH #15: “Most people would rather hear a pleasant lie than an unpleasant truth.” -Old Pithy.

Posted by PITHOCRATES - May 25th, 2010

“DO THESE JEANS make my ass look big?”  Men don’t like this question.  And when their wife or girlfriend ask it, they know to tread lightly.  Unless the relationship is on the outs.  In which case they may answer with something like, “No, it’s your fat ass that makes those jeans look big.”

If the man cares for the woman.  If he loves her.  If he ever expects to have sex with her again, he’ll say something nice.  No matter how much more of her there is to love back there.  It’s called a white lie.  Normally, we don’t base our relationships on lies.  But when it comes to the butt, though, lies are good.  They spare hurt feelings.  Should a person’s genes not bless them with a heavenly derriere to display in a tight pair of jeans.

White lies don’t hurt people.  In fact, we use them in order not to hurt people.  Such lies don’t have consequences.  And people may know you are lying.  Even expect you to lie.  It shows you care enough to make someone feel better about something you know they’re sensitive about.  Like her big butt.  Or his performance in bed (“Whew, that was the best five minutes of my life.  Really.”).

WHEN YOUR CHILD IS learning a musical instrument, he may make more noise than music.  But you encourage him.  Or her.  You tell them they’re good.  That they’re getting better every day.  And, yes, you would love for them to play in front of your visiting family.  And when they do, the family applauds and tells them they’re good, too.  Your child is encouraged.  And he or she keeps practicing.  A little white lie and no one gets hurt.

Suppose your daughter wants to sing.  She listens to the reigning pop queens and sings along.  Only thing is, she’s tone deaf.  She doesn’t sing well at all.  In fact, when she does sing, you start looking for a hurt cat because you’re sure no human could make such inhuman noise.  But you don’t want to hurt her feelings.  And you’re sure it’s just a passing phase.  So you tell her how wonderful she sounds.  No one gets hurt.  Nothing can go wrong with that, can it?

Well, suppose her school is having a talent show. Anyone can simply walk up to an open mike and do whatever they want.  And she wants to sing.  In front of her friends.  In front of her classmates.  In front of the 2 kids that always tease her.  Now the issue is a little more complex.  Do you tell her the truth about her singing and hurt her feelings.  Or do you let her sing.  And risk the kids laughing at her.  And teasing her about it afterwards?

BUT IT’S NOT just the white lies we want to hear.  Say your husband is staying later and later at work.  You call to see what time to expect him for dinner but there’s no answer.  When he comes home late you tell him you were worried.  You called and there was no answer.  He apologizes for worrying you and says he was with a client.  You’re relieved.

Or you come home from work and your wife isn’t there.  Concerned, you call her and there’s no answer.  When she comes home she says she was at the gym with a friend and left her cell in her gym bag.  You’re relieved.  Then she goes upstairs to shower.  Funny, you think.  She usually showers at the gym.

Learning about infidelity is not easy.  And it’s painful.  You ignore signs as long as you can.  You believe the lies.  You want to.  You need to.  Then you find an earring in the car that isn’t yours.  Or you bump into your wife’s friend who says she misses her now that she quit going to the gym.  Soon, the evidence forces you to face the awful truth.  And it kills you inside.  Divorce.  The children.  It’s just the beginning of so much bad to come.

SO WE LIKE it when people lie to us.  At times.  For the truth can be disagreeable.  Ugly.  Painful.  And we’d rather not have that pain.  No, we’d rather live life in a sitcom where there is always a good laugh and rarely anything bad ever happens. 

Politicians know this.  They know that most people don’t like the harsh realities of life.  So when they need to get elected, they lie to us.  No one wants to pay more taxes.  So the politicians promise that only the rich will pay any new taxes.  But massive government spending requires massive taxation.  And taxing the rich just can’t pay for it all. 

George Herbert Walker Bush promised no new taxes.  He said, “Read my lips.  No new taxes.”  He raised them.  Didn’t want to.  Said he had to.  To balance the budget.  Because he and Congress didn’t want to cut spending.  Same with Bill Clinton.  He promised there would be no middle class tax increase.  But there was.  He said he tried as hard as he could not to but had to.  Again, the spending thing.  No one wants to cut spending.  It doesn’t help win elections.

But we wanted to believe the lie during the campaign.  They promise us everything and say it won’t cost anything.  That’s what we want to hear.  We don’t want to hear the intricacies of monetary and fiscal policy.  That increased taxation dampens economic activity.  Decreases incentive for risk takers.  So they take fewer risks.  Create fewer jobs.  Which increases unemployment.  But we don’t want to hear this.  We just want the free stuff.  Just promise it.  Tell us it’s free.  And we’ll vote for you.

LITTLE WHITE LIES have little consequence.  We say them because we care about someone.  Other lies, though, do.  Big ones.  If we fall for them.  If we believe in an ever-expanding welfare state, we’ll keep voting ourselves the treasury.  Until we’ve emptied it.  And when there’s no more money, we’ll say, well, it was nice while it lasted.  But all good things must come to an end.  Or we’ll riot.

Or we’ll cut spending elsewhere to fund our insatiable appetite for free stuff.  Maybe we won’t build a new aircraft carrier.  Or we’ll close an overseas Air Force base.  Or we’ll reduce the size of our conventional forces.  Because we’ve been lulled into a false sense of security, we may think a large standing army is not necessary anymore.  But it was that large projection of force that gave us that sense of security.  It scared the bad guys.  Because the ability to project force, and the will to do so, will create consequences if the bad guys do act. 

During the boom of the 1990s, times were good and we got complacent.  During those good times, though, the bad guys hit Americans in a series of attacks (World Trade Center bombing, Tanzanian Embassy bombing, Kenyan Embassy bombing, Khobar Towers bombing, the USS Cole attack).  We didn’t fight back.  We lied to ourselves.  We didn’t want to believe that America was under attack.  Head in the sand, we wanted to continue to enjoy the good times.  This only emboldened our enemies.  They saw that America didn’t have the will to fight back.  So they upped the ante.  And in 2001, they attacked on 9/11.  And that attack was just too great not to awake a slumbering giant.

WE MAY NOT like the unpleasant things in life.  But they are part of life.  And we have to deal with them.  However unpleasant they are.  They are what they are.  No matter how we try to rationalize them away.


Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,