title: How to round a Double to the nearest Int in swift?
body: <p>I'm trying to make a calculator of growth rate (<code>Double</code>) that will round the result to the nearest Integer and recalculate from there, as such:</p>
  
  <pre><code>let firstUsers = 10.0
  let growth = 0.1
  var users = firstUsers
  var week = 0
  
  
  while users &lt; 14 {
      println("week \(week) has \(users) users")
      users += users * growth
      week += 1
  }
  </code></pre>
  
  <p>but I've been unable so far.</p>
  
  <p><em>EDIT</em>
  I kinda did it like so:</p>
  
  <pre><code>var firstUsers = 10.0
  let growth = 0.1
  var users:Int = Int(firstUsers)
  var week = 0
  
  
  while users &lt;= 14 {
      println("week \(week) has \(users) users")
      firstUsers += firstUsers * growth
      users = Int(firstUsers)
      week += 1
  }
  </code></pre>
  
  <p>Although I don't mind that it is always rounding down, I don't like it because <code>firstUsers</code> had to become a variable and change throughout the program (in order to make the next calculation), which I don't want it to happen.</p>