title: Haskell: Convert Double to Int
body: <p>I want to compute "which power of a number do I have to use" from a fixed base, e.g. 2. </p>
  
  <p>I want to find the next (integer) power of a number,  e.g. <code>2 ^ 3 = 8 ==&gt; get2Power 8 ==&gt; 3</code>.</p>
  
  <p>This is simple, but  <code>get2Power 10 ==&gt; 4</code>  since <code>2^3=8</code> as the lower bound and <code>2^4=16</code> as the upper bound I want to return the upper one, <code>4</code>. </p>
  
  <p>With simple math I know that I can calculate the power with some logarithm function, i.e. <code>log(x) / log(2)</code> which results in a Double. But I want to have the next <code>Integer</code>.</p>
  
  <p>My approach looks like</p>
  
  <pre><code>get2Power :: Integer -&gt; Integer
  get2Power x 
    | x &lt;= 0 = -1
    | otherwise = round (log(x) / log (2))     
  </code></pre>
  
  <p>which fails cause there is missing some conversion between the Types. The error message is not helpful to get an idea of what I'm missing. </p>
  
  <p>Could anybody give me a helping hand about how to transform the Double result into an Integer/int?</p>