title: Using NSNumberFormatter to generate number with trailing zeros after decimal
body: <p>In Swift, how would you create an <code>NSNumberFormatter</code> that would preserve trailing zeros after a decimal (12.000) while also generating a number appropriate for the current locale?</p>
  
  <p>My current code and example output:</p>
  
  <pre><code>let formatter = NSNumberFormatter()
  formatter.numberStyle = .DecimalStyle
  formatter.locale = NSLocale.currentLocale()
  formatter.maximumFractionDigits = 10
  
  var doubleNumString = "12.0"
  println(formatter.numberFromString(doubleNumString)) //in English it prints 12, want it to print 12.0
  
  var doubleNumString = "12.000"
  println(formatter.numberFromString(doubleNumString)) //prints 12, want it to print 12.000
  
  var doubleNumString = "12.125"
  println(formatter.numberFromString(doubleNumString)) //prints 12.125 as expected
  
  var doubleNumString = "1234"
  println(formatter.numberFromString(doubleNumString)) //prints 1,234 as expected
  </code></pre>
  
  <p>I've already coded it such that if the string ends in a decimal (<code>"12."</code>) then it won't use this formatter to generate the number and will instead just display the number then the decimal (but I will need to improve that because some languages read right to left).</p>
  
  <p>One solution would be to check if the string contains a period and if so, check if all digits that follow it are 0, and if so then don't run it through the number formatter and instead run only the int value through the formatter then append/prepend the decimal followed by the appropriate number of 0's.</p>
  
  <p>Is there a better/cleaner solution?</p>