title: Swift convert UInt to Int
body: <p>I have this expression which returns a <code>UInt32</code>:</p>
  
  <pre><code>let randomLetterNumber = arc4random()%26
  </code></pre>
  
  <p>I want to be able to use the number in this if statement:</p>
  
  <pre><code>if letters.count &gt; randomLetterNumber{
      var randomLetter = letters[randomLetterNumber]
  }
  </code></pre>
  
  <p>This issue is that the console is giving me this</p>
  
  <pre><code>Playground execution failed: error: &lt;REPL&gt;:11:18: error: could not find an overload for '&gt;' that accepts the supplied arguments
  if letters.count &gt; randomLetterNumber{
     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>The problem is that <code>UInt32</code> cannot be compared to an <code>Int</code>. I want to cast <code>randomLetterNumber</code> to an <code>Int</code>. I have tried:</p>
  
  <pre><code>let randomLetterUNumber : Int = arc4random()%26
  let randomLetterUNumber = arc4random()%26 as Int
  </code></pre>
  
  <p>These both cause <code>could not find an overload for '%' that accepts the supplied arguments.</code></p>
  
  <p>How can I cast the value or  use it in the if statement?   </p>