Boolean Logic: Binary Number Representation

    Boolean Logic: Binary Number Representation

      It's Saturday night, you're in the spot, and ready to get your grub on at your favorite restaurant: Bill’s Binary Bargain Bistro. Bill has some great deals, and you notice a new food on the menu: 11 churro-style onion rings for $1.00. Before now, you didn't realize what a great combination cinnamon sugar and fried onions could be, but it's 11 for a dollar; might as well try it out.

      Bill—a kindly old gentleman with a hint of Southern charm—takes your order and comes back with three rings. When you ask Bill what happened to the other eight (was there a batter shortage or something?), he tells you to check your base-10 privilege. The name of the bistro itself says binary in it, so of course all the counts are in binary.

      Ugh.

      Most numbers you're going to see in the real world come in the base ten variety. When you see 11 onion rings on a menu, you think of eleven steaming rings, rather than…uh, any other number.

      But 11 is just a short way of saying that the number is one more than the base number. Here's how that works in base 10.

      Each place of the number 11—one and…also one—equals a power of ten. One says that there's one set of 100 and the other one is one set of 101. For something like 1.35, you're going to get:

      Power of Ten10010-110-2
      Number135

      In the case of a number like 1.35 or 55, the numbers represent what we multiply the power of ten by in order to get the number we need at that place (5 × 100 for the 1s place and 5 × 101 for the 10s place). Add them together (5 + 50) to get fifty-five, which is equal to 55 in base ten.

      Binary's pretty much the same, except completely different.

      In base two, the number 11 represents three:

      Power of Ten2120
      Number11

      Finding the number is as simple as adding: (1 × 20) + (1 × 21). A large number like 10101 would equal [(1 × 20) + (0 × 21) + (1 × 22) + (0 × 23) + (1 × 24)]. All that equals the value twenty-one.

      If you're playing with bases and need to specify which base you're working in, just add a subscript of the base to the right of the number. So 10110 is the same as one hundred and one, but 1012 is five. Small difference, really.

      We're going to use that system from now on to help avoid another onion ring churro catastrophe.

      Potential Issues

      There are a couple of reasons why binary can be annoying to use (much less do anything useful with). You need them because computers can only communicate in yes-or-no answers, though, so be on the lookout for these problems.

      Problem 1: even small numbers suddenly take up piles of space. Take the number twenty-one. In base 10 we only need two numbers to write out the number. Using binary? Now it's five. Just image what a number in the hundreds or thousands is like.

      We'll tell you: a lot. The year 177610 takes up eleven spaces (11011110000) when written in base two.

      To make life a little less frustrating, you can represent large numbers in either octal (base eight) or hexadecimal (base sixteen) notation. Check out this site for more info.

      Problem 2: Computers want a string of 0s and 1s when they do anything to and/or with numbers. To make a number negative, you can’t just stick put a negative sign in front; a computer won’t understand that. There are two main ways you can get around it, so be on the look-out for it in Key Parts and How it Works