title: Double format with Swift
body: <p>I need to display double numbers in a <code>UILabel</code> but I have a rule if the number will double without having fractional value then it can be display in Integer format i.e. 4.0 just display 4 but if the number is 4.879770 just display two decimals round up.</p>
  
  <p>I made the first part works with:</p>
  
  <pre><code>let number = 4.99
  
  if number - Double(Int(number)) == 0 {
     print(Int(number))
  } else {
     print(String(format: "%.2f", number))
  }
  </code></pre>
  
  <p>But I hope that there is a better way</p>