How do binary numbers work?

My teacher has told us to learn how to count in binary but I’m a bit lost. How is 100 only one greater than 11?

Sounds like you’ve got a good computer science instructor there, asking you to figure out the basic number system that the tiny little CPU chips inside our computers use to keep track of everything from numbers to graphics, audio files to the latest movie release.
Turns out that there are four (reasonably) common numbering schemes that you can encounter on a computer system, though for obvious reasons most of them are reserved for programmers and hard core techheads.
The numbering system you’re used to is called decimal, or “base 10”. That means that each digit can represent ten different possible values. 0, 1, 2, 3… 9. Decimal numbers are built from the right to the left, so 35 is really 3*10 + 5 or, to be more proper, 3*(10**1) + 5*(10**0). 10**1 is ten raised to the first power, or ten. Bigger numbers break down more interestingly: 9353 = 9*(10**3) + 3*(10**2) + 5*(10**1) + 3*(10**0). The “9” is really 9*1000. You know that, you’ve probably just never seen it written this way.
The reason it’s considered decimal, or base ten, is because we use 10 as the basic value that we’re factoring.
Take that same smaller number, 35, and use an octal, or base 8, numbering system and you find that it represents 3*(8**1) + 5*(8**0) or 3*8 + 5 = 29 (base 10). Does that make sense? You couldn’t have 9353 in octal, however, because each digit can only represent the values 0,1,2..7, just as you can’t have a single digit represent the value 10 in decimal.
Octal isn’t used much any more, actually, but what you do still see as a software developer are both binary (base 2) and hexidecimal (base 16). (did you notice the pattern? Binary, octal and hexidecimal are all based on powers of 2. It’s not an accident)
These are considerably more complicated, and a single hexidecimal digit can represent the values 0,1, 2, 3…9, A, B, C, D, E, F where “A” = 10 decimal, “B” = 11 decimal and so on. So a hexidecimal value like F2 is actually F * (16**1) + 2 * (16**0) or 15*16 + 2 = 242.
Let’s focus on binary, though, as that’s what you’re asking about. Binary is the essential counting system of computers because as a base 2 numbering system, each digit can be represented electronically as on or off. 1 or 0. This means that binary numbers can get really long, really fast.
For example, 100 binary = 1*(2**2) + 0*(2**1) + 0*(2**0) = 4 + 0 + 0 = 4. 1000 = 1*(2**3) = 8, and so on. To count from 1-10 decimal in binary, the values look like this: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010.
Want to represent 35 in binary? It’s hard to calculate by hand, the answer is: 100011. Let’s get more scary. How about 9353 as binary? 10001110010010001001.
By contrast, hexidecimal is more compact, as we’ve already learned, so that same value 9353 in “hex” is represented as 253F. Let’s go bigger. 126,334,307 base 10 = 787b563 base 16.
Where this all gets interesting is when you start trying to work with what’s called irrational numeric bases like pi or e, but that’s a subject for another posting.
I hope this helps you out!

4 thoughts on “How do binary numbers work?”

  1. Oh, sorry, Nathan, the “**” is a power operator, so 4 squared is 4**2. In other words, “to the power of” if you’re reading it out loud. Some mathematical notations use “^” instead, as in “4^2”.

    Reply
  2. That’s a very interesting way to explain the different numbering schemes. It’s probably the right way to do it too from a mathematics standpoint. However, I personally like to think of binary as a set of switches with different values since the number can only be a 0 or a 1 (0 being off and 1 being on).
    Starting from the very right (moving right to left), each switch is worth twice as much as the previous switch. We start with the very first switch on the furthest right having a possible value of 1. If this switch is on (set to 1), then it’s worth 1, if it’s off (set to 0) then it’s worth 0. The next switch to the left of the first one is possibly worth 2. If this is on (set to 1) then it’s worth 2, if it’s off (set to 0) then it’s worth 0.
    The following switches are then possibly worth 4, 8, 16, 32, and so forth. Simply add up all the values of the switches that are on and you’ll get the value of the binary number in decimal.
    For example: 10011101 would be the equivalent of 1+0+4+8+16+0+0+128 = 157
    (Remember to read the values from right to left)
    Just thought I could bring a different way to look at binary to help your readers.

    Reply

Leave a Comment

Receive My Weekly Email Newsletter:

Your email address:*
First Name
Please enter all required fields Click to hide
Correct invalid entries Click to hide

Recent Posts

On My YouTube Channel

Date Archives