|
|
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!
More Useful Computer and Internet Basics Articles:
✔ How do I blur my house on Google Maps Street View?
I was poking around on Google Maps looking at satellite views of my neighborhood and when I switched to street view, was upset...
✔ Create a custom vanity URL for Kickstarter?I was reading some updates on Twitter and saw someone had posted a URL that would let me see what projects they'd backed...
✔ Export or Save Subscription List from Google Reader?Just heard that Google Reader is going away this summer. That stinks! How am I supposed to read my RSS feeds? More importantly,...
✔ Shrink or Reduce a Photo File Size on Mac?I'm trying to upload some photos to a social media site and it's complaining that they're too big. They are, as they come...
✔ Can I organize my Yahoo Mail with folders?I've been on Yahoo Mail for years and while most of my friends are now on Gmail or their own Web-based email programs,...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
Computer and Internet Basics
(Article 9623,
Written by Dave Taylor)
Tagged: binary, computer science, decimal, hexidecimal, math, numbering systems, octal Previous: Test for valid numbers in a Bash shell script? Next: Can I view specific Google searches over time? Reader Comments To Date: 4Nathan said, on October 26, 2010 5:53 PM:
Can you explain the ** operator? I haven't come across it before (which is odd because I have come across ++ and xor). Dave Taylor said, on October 26, 2010 6:16 PM:
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". Nathan said, on October 26, 2010 8:34 PM:
Thank you for explaining it dave, that clears things up.
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help Find Me on Google+ ADT on G+ |
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.