Learning Binary

I have always been fascinated by binary, and would like to share my fascination with you. Lets start with this quote.
“There are only 10 types of people in the world, those who know binary and those who don’t”
You will understand this quote by the end of this tutorial!

What are bits?

To understand bits is to understand binary. They coincide.
Bits is the abbreviation for binary digits.
Binary Digits
Binary represents two numbers since its a base 2 numbering system which uses electrical circuits. It uses the numbers 1’s and 0’s.
Each bit represents a single switch in a circuit.
Think of a light switch. There is on and off.
Same concept in binary.
1 would be on and 0 would be off.
If the gate is open (1) electricity can flow through.
If its off (0) then electricity is blocked.
Each bit is a binary digit. But eight bits equal a byte.
Half of a byte is a nibble which is four bits.
Analogy:
You have eight cookies in front of you. So you have a byte. But if you were hungry and ate four cookies. Then you would have nibble.

But why not use the decimal numbering system in computers?

The decimal number systems use the digits 0,1,2,3,4,5,6,7,8,9.
Ten digits(numbers) for ten fingers and ten toes.
Computer does not have toes or fingers.
As you read above it has electronic circuits. On and off.
If you used the decimal number system there would have to be ten states instead of two. Which means its more complicated and less reliable to represent the numbers. Computers now don’t have the technology to create more then two states since the switches in the circuits are changing constantly. It is logical to have only two states because with more states the system would need to constantly convert between them.
Think of this: Ten light switches in your room with the option on and off. Now that would make for a hard time. It would make more sense to have two states. Just on and off. That would be less of a hassle.
Remember the saying: Less is more

Reading binary

As you have learned binary is in the base of two. So you multiple two to each number.
1×2=2 2×2=4 4×2=8 8×2=16
Your getting the picture. You start from right to left.

128 64 32 16 8 4 2 1

For each number you use you put a 1(on). For a number you don’t use you put a 0(off).

Example: 13 in binary
1 1 0 1 – Would be 13 in binary.
8 4 0 1

1 + 0 + 4 + 8 = 13
For the number I did not used I placed a 0.

Another example: 21 in binary
1 0 1 0 1
16 8 4 2 1

1 + 4 + 16 = 21

Now you should you know what the binary quote means above.
“There are only 10 types of people in the world, those who know binary and those who don’t”
10 = 2 in binary
2 + 0 = 2
As you can understand for the quote, it’s saying…
“There are only 2 types of people in the world, those who know binary and those who don’t”

Soon there will be coming a lesson on how to add, subtract, multiply, and divide binary numbers. Also how to convert binary to hex and hex to binary.

Read More

5 Comments

  1. Great peice on binary! I have always wondered about it but never seem to find a good tutorial that is using a basic language that I can actually interpret. 😛 I can understand your tutorial very well. I learned a lot here! 🙂

  2. I remember learning about binary in one of my computer classes in college. I also learned about it in my Math for Elementary Teachers course, believe it or not. Learning about base two (binary), base three, etc. helped us look at the decimal system a slightly different way.

    1. I am curious what class is that?
      That is so awesome you learned about it in your math elementary teachers course.
      You are right. It does make you look at the decimal system a different way.

    2. Thank you very much for your explanation , I have found a folmrua of converting decimal to binary in a website that works for me but I really don’t understand how it works (it uses shift and || ):my $number = shift || $decNumber;Could you please explain how this works ?Thanks in advance.

      1. I apologize in advance for my late reply to your comment.
        Its bit shifting.
        What programming language that code is in I’m not sure exactly.
        But I can evaluate it and break it down for you.
        But || is an operator in a programming language. Its a boolean or operator. Its based on boolean logic.
        True or false.
        The OR operator.
        It compares two expressions.
        An expression is a value that represents a variable.
        a + b = $bob
        A variable is a value that can be held and used for later.
        A variable can be thought of as a bucket. You store information in a bucket. But can be used later. Same as a variable.
        Lets take this for example for the OR operator.
        Do you like pizza or ice-cream better?
        I comparing the first expression pizza to the second comparison ice-cream.
        Its true if you like pizza and ice-cream.
        Its also true if you like either better.
        But what if you don’t like pizza or ice-cream at all.
        It will return false.
        $number is a variable. Same as $decNumber
        $number = shift
        Shift the variable $number OR $decNumber
        Shift the variable $number then compare it to the variable $decNumber.
        Bit shifting is shifting bits to the left or right.
        01101
        If you shift a bit to the left << then the digits shift to the left from one position.
        Shifting to the left you would get…
        11010
        We shifted 01101 to 11010

        ———
        0 gets added to the end of the byte.
        If you shift a bit to the right >> then the digits shift to the right from one position.
        Shifting to the right you would get…
        001101
        ———
        We shifted We shifted 01101 to 001101
        0 gets added to the beginning of the byte.
        I hope this helps. If you have any more questions feel free to ask. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *