title: Multiplying UInt64 by a Float
body: <p>I have the following code in a playground:</p>
  
  <pre><code>import Foundation
  
  var test : UInt64 = NSEC_PER_SEC // NSEC_PER_SEC is a CUnsignedLongLong
  var test2 = 2 * test // this works
  var test3 = 1.5 * test // this doesn't work
  </code></pre>
  
  <p>I'm trying to get a <code>Int64</code> value that is the number of nanoseconds in some <code>Float</code> representation of seconds for use with <code>dispatch_after</code>.</p>
  
  <p>I've tried several variations of type casting, but I can't seem to come up with a way to get this result. </p>
  
  <p>Any suggestions would be appreciated!</p>
  
  <h2>Solution</h2>
  
  <p>The solution in the answer below (thanks to @shucao) is to do the following:</p>
  
  <pre><code>var test3 = 1.5 * Double(test)
  </code></pre>
  
  <p>Interestingly, Swift takes <code>1.5</code> to be a <code>Double</code> as well. So, for instance, this does <strong>not</strong> work:</p>
  
  <pre><code>var flt : Float = 1.5
  var test3 = flt * Double(test) // doesn't work
  var test3 = Double(flt) * Double(test) // does work
  </code></pre>
  
  <p>So, in order to find the number of nanoseconds in an arbitrary number of seconds, both values have to be cast to <code>Double</code>s.</p>