I received the results of one of my tests on Wednesday, and caused a bit of a debate with my professor. It was in C++ class. One of the practical portion questions was pretty simply:
Write a piece of code that will use a for loop to calculate the number of digits in a positive integer (Hint use division by ten)
So I created a short, simple function:
int digits(int num)
for (i = 0; num > 0; i++, num /= 10);
To my surprise, I only got 3 out of 4 on that question. Apparently, the loop was supposed to start at 1 (rather than 0), and the test changed to > 9. This would result in 0 having one digit.
I’m not sure what exactly lost me the mark, but it was either that or the fact that my teacher though this would produce “10″ as having one digit, which he tried to explain to me that my logic that produced no digits for zero, as produced one digit for ten, and so forth (which it didn’t).
I had two arguments to his reasoning, and why my function that produced an output of 0 for an input of 0 was correct:
- The question called for a positive integer. While zero surely is an integer, there’s a lot of confusion amongst most people if it’s truly positive or not. I personally believe that zero isn’t positive, but rather non-negative. I haven’t read any definite proof, and tried to show my teacher some opinions (a Dr. Math article), but he came back with some weird story about how my grade school teachers lied to me (more on that after).
- How many digits does zero have? I’ve heard less about this than I have about the positivity of zero, but I really think it’s kind of trivial, and it has no digits. What does zero represent? The absence of something. It means there’s nothing. So, no digits? Zero could be said to just be the leading zero to … well, nothing. The number “1″ has 1 digit, but it can also be represented as “01″, but it still only has 1 digit. So, does the “0″ digit in the number 0 really have digits? I don’t think so, but I’m not really certain on this one.
Anyways, I put up a good enough argument that my teacher gave me the mark (which I didn’t really care about anyways – I ended up getting 1% less than I could have had I not, due to my teacher’s bonus-marks-for-test-corrections theory). I was really trying to prove something, and have some good math talk (which I haven’t really done in a while).
At one point, my teacher asked where we learned that 0 isn’t positive, and one of my friends said “grade school”, which my professor then went on to say our teachers had lied to us, and “oh, hears something else that your teachers lied to you about! How did they teach you to do exponents?”. I knew he was going to bring up “x to the power of 0″ and say how it didn’t work with the common way of working out exponents (which is to multiply the number by itself how ever many times). I understand what he meant, but it also got me thinking about zero’s part in exponents, which I still haven’t figured out in my weird brain-logic I like to do. I’d like to show him the proof of 1+1=2, or how 1=0.9…
I’d appreciate some discussion on this, and perhaps some more scholarly or scientific opinions, as I’m not a math major nor do I really know that much about what I talk about.