1. Technology
Send to a Friend via Email
Computer Number Systems
    With Peter Zilahy Ingerman
Numbers

Although today's programming environments are becoming increasingly visual and graphic, numbers are still at the root of everything a computer does. It may look like a textbox, icon, or sound like a WAV file, but it's really just numbers. And, in fact, it's really just binary numbers.

So, even though it's possible to program for quite a while and never really run into a requirement to understand all the ways that a computer deals with numbers, sooner or later every programmer will need this fundamental knowledge. Here's a dose of fundamentalism to prepare you for that unavoidable day!


 More of this Feature
• Part 2: Hex, Octal, and what is "Radix"
• Part 3: Numbers in Visual Basic
• Part 4: The Other VB Numerals
 

This mini-series of three articles began with the article Calculating a Contrasting Color Code. In that article, we used several hexadecimal numbers as a mask in a Visual Basic program. Although this is one of the most frequent uses of 'Hex' in programming, it isn't the only one.

In this article, we're going to cover the use of numbers in a computer from two points of view. First, we're going to look at the very lowest level: abstract number systems starting with binary, but then broadening our understanding to include what are called radix number systems. These include octal, decimal, hexadecimal or actually, any base. A fundamental understanding of radix numbers opens the knowledge doors so that none of them will ever confuse you again. It's something that is worth knowing!

After we cover radix number systems, we'll look at some of the different ways that Visual Basic represents other numbers. Actually, this is knowledge that programmers need slightly more often than the fundamentals because it often makes a real difference in how program logic works.

At the very root, a computer doesn't know anything about strings, properties, objects, data types and the rest of it. The computer only knows 1 and 0. In the first two segments of this series, we discussed computer logic - And, Or, Xor and so forth. It has always helped me to know that right at the electronic circuit level in computers, what is actually happening is that solid state logic gates are executing the same kind of logic used in programming. One big difference is that circuits ALWAYS work with binary numbers. A very common logic gate used in circuit design is the NAND gate (Not And) because it's possible to build complex logic assemblies using only this gate. If you're curious, you can get a peek at logic design using the NAND gate here.

Rather than just jumping into binary, lets start our discussion with a familiar four digit decimal number chosen pretty much at random: 1,234 - one thousand, two hundred and thirty four. The first thing to understand is that the number VALUE of any numerals used to represent that value is the same. If you had that many rocks in a bag, you could say you had 1,234 rocks or 10011010010 rocks or 4D2 rocks. The actual number of rocks doesn't change; only the numerals used to describe the number changes. Since computers and circuit design engineers can get along just fine using only binary, the whole purpose of any other number system is just to make it easier for you and me to understand. If you could immediately recognize and conveniently work with numbers like 10011010010, there wouldn't be any real reason to use anything else. But I have difficulty doing that. Consequently, we convert 10011010010 into 1,234 so we can work with it as programmers. (Next time you go shopping, tell the clerk at the grocery store that you want 1100 eggs.)

Next page > Hex, Octal, and what is "Radix" > Page 1, 2, 3, 4

©2014 About.com. All rights reserved.