title: What's the best way to do math with CGFloats in swift?
body: <p>I tried to do some simple UIView layout math in swift and tried the following line of code...</p>
  
  <pre><code>var offset: CGFloat = (bounds.width / 2.0) - ((sortedSymptoms.count * bounds.height) / 2.0)
  </code></pre>
  
  <p>and got the following error from the compiler:</p>
  
  <pre><code>cannot invoke '-' with an argument list of type '(($T6), ($T17))'
          var offset: CGFloat = (bounds.width / 2.0) - ((sortedSymptoms.count * bounds.height) / 2.0)
                                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
  </code></pre>
  
  <p>The compiler error isn't all that helpful, but it looks like there's a type conflict between Double, Int, and CGFloat of some kind. I was able to get the line to compile by sprinkling in some explicit creations of CGFloats, but I can't believe that this is the right way to do this.</p>
  
  <pre><code>var offset: CGFloat = (bounds.width / CGFloat(2.0)) - ((CGFloat(sortedSymptoms.count) * bounds.height) / CGFloat(2.0))
  </code></pre>
  
  <p>What's the right way?</p>