# Thread: Help With Simple Summation...

1. Originally Posted by quzah
What are you talking about? Rather, who are you talking about? That's what the 'quote' button is for. Mine works fine. It even does negatives; I know, I tested it.

Quzah.
Good to see that I'm not the only one confused by this.

>>And how do you propose we handle situations were a person wants to sum up say like:
12 and 15? Your solution breaks down.

This is immaterial - If I'm not mistaken (and I stand to be corrected by the OP if I am), the
task is to enter a sequence of digits and add all the individual digits entered up - last I checked,
in the base 10 number system, 12 and 15 are not single digits. Basically I think that your
interpretation of the task is to enter a certain amount of numbers (note, not digits) and add
them all up. I don't think that this is the case, and apparently neither does quzah. Quzah's
solution solves his interpretation of the task just fine.

This whole thing could be avoided if the OP had expressed his question more clearly.

A couple more things:

1: >>The wrong number. Ie, undefined behavior.

I think you need to look up your definition of undefined behavior - such as using atoi without
including the correct header - that's undefined, getting the "wrong number" isn't specifically

2: It's never a good idea to challenge "certain" people on this forum (in this case, quzah),
unless you're on rock solid ground - it just doesn't end pretty. Just because you mightn't see
his code lying around here that often, doesn't mean he's not right when he points out people's
mistakes either. Quzah - you either love him or hate him

2. Originally Posted by cdalten
Q, I could be a real dick and say ask your local college for a refund, but a demo from my computer is enough.
There is no "demo" from your computer, because you didn't do what you imply you did. You're lying to try and make your point.
Originally Posted by cdalten
now I try 12 and 15
\$./sumit
1215

9\$

The wrong number. Ie, undefined behavior.
It's not undefined behavior. You entered one number. Let me teach you a little bit about basic base-10 math. Then you might want to call your elementry school and ask for some classes.

Here we have the concept of a digit. A digit is a single character, in base ten, ranging from 0 to 9. The digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Zero (0) is the smallest, and is usually used to represent "nothing". 9 is the largest, and is used to represent ... nine. Count on your fingers if you need to. Here's a hint, it's all of your fingers, including thumbs, minus one. I know, that was a bit unfair of me, since I haven't gone into subtraction yet. But play along.

Now, what happens when we have more than nine? You know, like all your fingers, plus both thumbs. Well then we have another digit. This digit goes beside the first, to the left of it. As we increase in digits, each one gets placed to the left. Each digit represents a pile of the maximum digit of the previous field, plus one. That is to say:

10

Represents nine + 1.

Then you start incrementing (that is to add, or increase by one) the right hand digit one at a time, until it reaches nine again, at which point you reset it to zero, and increment the one digit to the left of that by one. If ever you run out of left most digits, you just add one more on top of that.

We'll ignore decimals for now, because I don't think you're up to it.

Anyway, what does this all have to do with you? Ah, here we go:
Originally Posted by cdalten
now I try 12 and 15
\$./sumit
1215

9\$

The wrong number. Ie, undefined behavior.
See, you didn't enter "12 and 15", you entered a single four digit number. Remember above where I said if they're all side by side it counts as a single number with multiple digits? Yeah, that's what you did. Oh! Just like the OP's original example! See, they didn't enter "12" and "34" and "5". They didn't enter "1" and "23" and "45". They didn't enter "1" and "2" and 34" and "5", or any other combination of more than one number. No, that counts as a single five digit number. You know, like they said they wanted.

Therefore, we deduct, you know, with basic mathematics, that you didn't in fact enter 12 and 15, you instead entered "1215", which summed up gives you nine. Holy ........! It is the right number after all!

You really should look into that elementry school thing.

Quzah.

3. Quzah: 1
Opponent: 0

How the [insert profanity here] do you know Quzah hasn't had anything to his name? What if he's all of the lead GCC developer? What if he's Bjarne in hiding?

And looky here, he's posted a 1-1/2 page elementary-school lesson for a person who insults him in public. You brashly attacked the poster, not the post by insulting Quzah personally and no matter how wrong he was (if he was wrong) about the code you have actually breached netiquette.

4. Quzah's rebuttals are better than anyone else's on this board, but just for the record he was never wrong. I suppose it's just that other people refused to understand his advice. While I could speak volumes about how retarded that is, the thread is over.

How do I sage?

5. It's not going anywhere, and the OP can't be bothered to contribute to their own thread - closed.