title: How to round off decimal number to 2 digits in iphone?
body: <p>How can we round off decimal numbers to 2 digits in iphone ?</p>
  
  <p>For example ,</p>
  
  <ol>
  <li><p>5345 --> 53</p></li>
  <li><p>570 -- > 57</p></li>
  <li><p>89523  -- > 90 </p></li>
  </ol>
  
  <p>I tried to use nsformatter for this and here is the code i used ,</p>
  
  <pre><code>    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
  [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
  [formatter setMaximumIntegerDigits:2];
  [formatter setRoundingMode: NSNumberFormatterRoundUp];
  
  NSString *numberString = [formatter stringFromNumber:[NSNumber numberWithInt:570]];
  
      [formatter release];
      NSLog(@"%@",numberstring);
  </code></pre>
  
  <p>I keep on getting the value as 70 even after changing the rounding mode to different options. Please help me with this </p>
  
  <p>Thanks,
  Vinod.  </p>