title: Objective C: calculator app - currentNumber = currentNumber * 10 + digit;
body: <p>I am reading "Programming in Objective-C" 4th Ed. by Stephen G. Kochan. In the book, there is a sample code for creating a Calculator application for the iPhone. I understand the code, at least 90% of it. - There is a Fraction class that has methods to store fraction objects and that describe how to perform different basic fraction arithmetic operations
  - In addition to that, there is a calculator class that runs the appropriate methods from the Fraction class depending on whether the user is trying to sum, divide etc.</p>
  
  <p>The view controller has the following method for when the user presses a number in the interface:</p>
  
  <pre><code>-(IBAction)clickDigit:(UIButton *)sender {
  int digit = sender.tag;     //sender or the argument inthis case is  the button
  
  [self processDigit:digit];
  }
  </code></pre>
  
  <p>As you see this method is now called:</p>
  
  <pre><code>-(void) processDigit:(int)digit {
  currentNumber = currentNumber * 10 + digit;
  
  [displayString appendString:
   [NSString stringWithFormat:@"%i", digit]];
  display.text = displayString;
  
  }
  </code></pre>
  
  <p>My ONLY question (and probably the one with the most simple answer) is: Why is currentNumber always multiplied by 10? The value of currentNumber is always 0 by the time the compiler enters the method above (I verified this using the debugger in XCode) so i dont get why we even have to multiply it by 10. I did delete that multiplication and the results are incorrect, i just cannot figure out why yet. </p>
  
  <p>Thank you</p>