title: How do I incorporate decimals into calculator in objective c?
body: <p>The following is my app made in Xcode with Objective C. This is ViewController.m</p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      valueString = @"";
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  -(IBAction)tappedClear:(id)sender
  {
      total = 0;
      valueString = @"";
      label.text = @"0";
  }
  -(IBAction)tappedNumber:(UIButton*)btn
  {
      int num = btn.tag;
      if (num == 0 &amp;&amp; total == 0) {
          return;
      }
      if (lastButtonWasMade) {
          lastButtonWasMade = false;
          valueString = @"";
      }
      NSString *numAsString = [NSString stringWithFormat:@"%i",num];
      valueString = [valueString stringByAppendingString:numAsString];
      NSNumberFormatter *formatter = [NSNumberFormatter new];
      [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
      NSNumber *n = [formatter numberFromString:valueString];
      label.text = [formatter stringFromNumber:n];
      if (total == 0) {
          total = [valueString intValue];
      }
  }
  -(IBAction)tappedPlus:(id)sender
  {
      [self setMode:1];
  }
  -(IBAction)tappedMinues:(id)sender
  {
      [self setMode:-1];
  }
  -(IBAction)tappedEquals:(id)sender
  {
      if (mode == 0) {
          return;
      }
      if (mode == 1) {
          total +=[valueString intValue];
      }
      if (mode == -1) {
          total -=[valueString intValue];
      }
      if (mode == 2) {
          total *=[valueString intValue];
      }
      if (mode == 1/2) {
          total /=[valueString intValue];
      }
      if (mode == 10) {
          total *=[valueString intValue];
      }
      valueString = [NSString stringWithFormat:@"%i",total];
      NSNumberFormatter *formatter = [NSNumberFormatter new];
      [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
      NSNumber *n = [formatter numberFromString:valueString];
      label.text = [formatter stringFromNumber:n];
      mode = 0;
  
  }
  -(IBAction)tappedMultiply:(id)sender
  {
      [self setMode:2];
  }
  -(IBAction)tappedDivide:(id)sender
  {
      [self setMode:1/2];
  }    
  -(IBAction)tappedDecimal:(id)sender
  {
  
  }
  -(IBAction)tappedPercent:(id)sender
  {
      [self setMode:10];
  }
  
  -(void)setMode:(int)m
  {
      if (total == 0) {
          return;
      }
      mode = m;
      lastButtonWasMade = true;
      total = [valueString intValue];
  }
  
  @end
  </code></pre>
  
  <p>The following is my ViewController.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController
  {
      int total;
      int mode;
      NSString *valueString;
      IBOutlet UILabel *label;
  BOOL lastButtonWasMade;
  }
  -(IBAction)tappedClear:(id)sender;
  -(IBAction)tappedNumber:(UIButton*)btn;
  -(IBAction)tappedPlus:(id)sender;
  -(IBAction)tappedMinues:(id)sender;
  -(IBAction)tappedEquals:(id)sender;
  -(IBAction)tappedMultiply:(id)sender;
  -(IBAction)tappedDivide:(id)sender;
  -(IBAction)tappedDecimal:(id)sender;
  -(IBAction)tappedPercent:(id)sender;
  
  @end
  </code></pre>
  
  <p>I have each button tagged in Main.storyboard to get rid of excess code. 
  Basically, I would like to have a decimal button that works, a percentage button that works, and a division button that works. I also want to clear the screen when a new digit is entered after the equal sign is pressed.</p>
  
  <p>I'd import pictures but I have no reputation.a</p>