title: Swift 3:fatal error: Double value cannot be converted to Int because it is either infinite or NaN
body: <p>When I call this method, an error received. How to handle NaN or infinite  value during assign to hour, min or sec?</p>
  
  <p>Here is my code: </p>
  
  <pre><code>private func secondsToFormattedString(totalSeconds: Float64) -&gt; String{
      let hours:Int = Int(totalSeconds.truncatingRemainder(dividingBy: 86400) / 3600)
  
      let minutes:Int = Int(totalSeconds.truncatingRemainder(dividingBy: 3600) / 60)
      let seconds:Int = Int(totalSeconds.truncatingRemainder(dividingBy: 60))
  
      if hours &gt; 0 {
          return String(format: "%i:%02i:%02i", hours, minutes, seconds)
      } else {
          return String(format: "%02i:%02i", minutes, seconds)
      }
  }
  </code></pre>