So I finally have my program nearly running, but am having some problems with getting my multiplication to work properly:
I think it's a problem with carrying, and it throws my numbers off quite a bit...sometimes. Smaller numbers, where you don't have to carry or only have to carry a few places, it's no problem. But for some reason once you get into carrying quite a bit, it's a huge problem. It's difficult to debug it because it requires going through some LONG multiplication. So I am hoping somebody will be able to spot something in my code that I can't.
(For example: 123*456 yields 41310108 when it should be 56088 - that's a pretty significant 'carrying' error!)
Your ten's place variable is named "high" so why are you possibly adding it twice. I would rethink this logic:
You are saying if the ten's place is greater than 1 add that value to a certain place in the answer array. Then...always add that value to an additional place in the array? I suspect this isn't what you meant to do.
Lastly, each index inside your array should not have values greater than 10 because each one of them is supposed to be representative of 1 position in a normally represented number. I suspect that when you are adding your ones place and tens place number to answer it goes above 10 and when this happens you are not carrying. So when you add high and low to your array I would check in case this number goes above 9 redo your carry logic.
For example if you have 9 9 9 inside your answer array and you add 1 to the value at index 2 you currently are not checking for values > 9 so it would appear 9 9 10 when you printed it instead of checking.
Joined: Nov 15, 2007
Yeah it was something along those lines exactly, just figured it out actually. Thanks for the tips!