Binary Basics

# learning# binary# basics

 

     Imagine for a moment the light switch found on most walls. There are two settings: on, and off. This translates to binary, a 1 (on) and a 0 (off). Binary is what computers run programs as - a stream of zeros and ones that form the basic form of computer language. Computers rely completely on humans to instruct them in what to do, which requires programs that break down into binary. Since computers don't actually think, they can't automatically assume that when you tell them to make a bowl of cereal that every bowl of cereal requires a bowl, cereal, milk, and a spoon. Because they can't really "think" about a task abstractly, they must be told how to perform every single step of a task, and they must be told to use that sequence every time. Here is an example of asking a human to make a bowl of cereal and telling a computer how to do it.

 

Human:
go make a bowl of cereal, any kind will do.
done.

 

Computer:
Go to the kitchen.
open the fridge
     get out the milk
     place the milk on the table
close the fridge
open the cabinet
     get a bowl
     place the bowl on the table
close the cabinet
open the drawer
     get a spoon
close the drawer
put the spoon on the table
open the pantry
     get the cereal
     open the cereal
          pour 2 cups of cereal into the bowl
     close the cereal
     put the cereal into the pantry
close the pantry
pour 1 cup of milk into the bowl
open the fridge
     place the milk into the fridge
close the fridge
Done.

 

If that sounds complicated, well, it is. Any person that has ever had a child or been around a child as they are raised will understand this procedure. Children, much like computers, come blank from the factory. They learn everything in steps, and if you make a mistake in the steps then the child (or computer) is more than willing to continue on messing up until you fix things. Now, for a more practical example that applies to computer programming, we can do the same thing with recording a person's name and then printing it out.

 

Print "please enter your name: "
wait for input, then store in string userName

Print "please tell me your favorite whole number: "
wait for input, then store in integer favoriteNumber

Print "The name you entered is: " + userName + " and your favorite number is: "  + favoriteNumber