Support this page!
Buy my books!
151.androidapps.png cover
Even more books!

Departments

Home

Blog

Books

Training

Support

Dictionary

Fun


October 10, 2008

What is Zero, Anyway?

Filed under: Main — Tags: — admin @ 12:01 am

Oh, the fun folly of the land of mathematical puzzles. I love it. I don’t consider myself to be good at math, but I enjoy reading books on math, and looking at the various mathematic theories and postulations, such as π, √-1, and e. But when it comes to computer programming, a key question deals with the value of zero.

Zero is nothing, of course. But in programming zero can mean a bunch of things:

0 is merely a state. It’s the opposite of 1, but it’s not exactly nothing. As such 0 is often taken to mean the value false whereas 1 is the value true. Zero could also be off and 1 the value on.

What I’m writing about is binary, or the 1s and 0s that make up all the information stored in a computer. A binary digit, or bit, is either 1 or 0.

When doing math in a computer, of course, zero means zero or nothing. When you subtract 5 from 5, the result is zero according to the computer, a value. The computer doesn’t do math with only a single bit. It uses bits in groups of 8, 16, 32, or 64. In that case, the value zero is any of the following:

0000 0000
0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

(Yes there are also 128-bit wide values, but you get the point.)

Zero is also a character. The ASCII character codes are defined as zero through 127. As such the zero character is defined as the null, or empty character. That’s not the same thing as the space character, which is given code 32. In man programming languages, such as C, character code zero is used to mark the end of chunk of text.

Chunks of text are called strings. So, technically, character code zero is the string termination character.

Because zero is the value of the null character, some beginning programmers confuse the concept of NULL with the null character, or even with the value zero. They’re not the same things.

NULL is used in programming to represent an empty value, like a house with no one inside. So, for example, say there is an integer variable that can store only values from -32,768 up to 32,767. (Integers are whole numbers, no fractions.) If the variable stores the value zero, then the variable’s value is zero. But if the variable’s value is NULL, then the variable exists but doesn’t really contain any value.

Sure, a NULL variable could be zero. But the idea is that the value is “undefined.” Therefore if you assume that it’s zero, you make a big programmer boo-boo. You might be right, but you’re probably wrong. Either way, you would be misusing the NULL idea. That’s because you call kinds of variables can have NULL values, including those that store text, complex database information, even files on disk. Those things can’t be zero, but they can be NULL.

Confusing? You bet! That’s why I wrote my programming books. Pick up a copy of C For Dummies if you want to learn more.

Oh, and one other thing that I learned from those math books: The value zero has been proven to not be the same as the value of infinity. Sorry to dash your hopes!

1 Comment

  1. It’s like you’re keeping track of my classes! Last week or so we were learning about character arrays(as opposed to using the String class) in C++ and that the NULL character must be used to define the end of the array. Interesting stuff.

    Then we get to talking about ‘Nothing’ in Visual Basic.Net. *haha*

    Comment by Mel — October 16, 2008 @ 6:23 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Copyright © 2017 Quantum Particle Bottling Co.
Powered by WordPress