title: Swift 4: Getting first two digits in float
body: <p>i am trying to get the first two digits in a float that changes continuously, i tried <code>%.05f</code>,<code>%.5f</code> <code>%.3f</code>, but it didn't work,</p>
  
  <p>the code i used</p>
  
  <pre><code> let str = NSString(format: "%.01f", Float(totalBytesWritten))
  </code></pre>
  
  <p>the value (float) i created looks something like this <code>294525.0</code>, but i want to get the first two digits, something like  <code>29</code></p>
  
  <p>Thanks</p>