title: Having trouble using NSNumberFormatter for currency conversion in iOS
body: <p>I have a UITextField that receives numeric input from the user in my application.  The values from this textfield then get converted into currency format using NSNumberFormatter within my shouldChangeCharactersInRange delegate method.  When I enter the number "12345678", the number gets correctly converted to $123456.78 (the numbers are entered one digit at a time, and up to this point, everything works smoothly).  However, when I enter another digit after this (e.g. 9), rather than displaying "1234567.89", the number "1234567.88" is displayed.  If I enter another number after that, a totally different numbers after this (I'm using the number key pad in the application to enter the numbers.  Here is the code that I have:</p>
  
  <pre><code>NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
  [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
  modifiedValue = [formatter stringFromNumber:[NSNumber numberWithFloat:[modifiedValue floatValue]]];
  textField.text = modifiedValue;
  </code></pre>
  
  <p>The line that causes this unusual conversion is this one:</p>
  
  <pre><code>modifiedValue = [formatter stringFromNumber:[NSNumber numberWithFloat:[modifiedValue floatValue]]];
  </code></pre>
  
  <p>Can anyone see why this is?</p>