title: This expression has type int but is here used with type unit
body: <p>I'm trying to get the exact equivalent (not functional) of this vb.net code in F#:</p>
  
  <pre><code>Function FastPow(ByVal num As Double, ByVal exp As Integer) As Double
     Dim res As Double = 1
     If exp &lt; 1 Then
        If exp = 0 Then Return res
        exp = -exp
        num = 1 / num
     End If
     Do While exp &gt; 1
        If exp Mod 2 = 1 Then 
           res = res * num
        num = num * num
        exp = exp &gt;&gt; 1
     Loop
     Return res * num
  End Function
  </code></pre>
  
  <p>I wrote this:</p>
  
  <pre><code>let FastPow num exp =
     let mutable ex = exp
     let mutable res = 1
     let mutable n = num
     if ex &lt; 1 then
        if ex = 0 then res
        ex &lt;- -ex
        n &lt;- 1 / n
     while ex &gt; 1 do
        if (ex % 2 = 1) then 
           res &lt;- res * n
        n &lt;- n * n
        exp &gt;&gt;&gt; 1
     res * n
  </code></pre>
  
  <p>but in the line "if ex = 0 then res" at res I got an error:<br>
  "This expression has type int but is here used with type unit". 
  I cannot understand why it gives me that error.<br>
  Edit: i actually got a warning as well:<br>
  "This expression should have type 'unit', but has type 'int'."<br>
  at "if (ex % 2 = 1) then"</p>