Need guidance on adding characters
Right now I have three stacks. Each stack holds characters, with the normal operations of pushing and popping. I am trying to compare two characters from stack1 and stack2(each character is a digit character). I would like to be able to do arithmitic on the digit characters and the push the answer on to a result stack.
Ex.) I pop character '3' from stack1 and '5' from stack2. Then I add the two. equaling '8' and pushing that character on to the result stack. This will hopefully in turn allow me to add arbitrary large numbers that integers will not support.
I am having trouble because I believe I am getting some ascii character values when I pop off the result stack. here is a small piece of my code
public void addition()
char temp1 ,temp2;
int i = s1.getSize();
for(int j= 0;j<i;j++)
temp1 = s1.pop();
temp2 = s2.pop();
//If the carry is not present
Can anyone give me some pointers on how to go about doing this?
EDIT: NVM figured it out
Re: Need guidance on adding characters
You will want to use Character.getNumericValue(temp1) to convert temp1 and temp2 into integer values.