title: Power Function in Haskell: No instance for (Floating Int) arising from a use of `**'
body: <p>I have the following function:</p>
  
  <pre><code>probIndex idx xs = 
    xs!!idx+mult
    where mult = round(2**idx)
  </code></pre>
  
  <p>When I try to load it in ghci, it shows the following error:</p>
  
  <pre><code>Prelude&gt; :load bn.hs
  [1 of 1] Compiling Main             ( bn.hs, interpreted )
  
  bn.hs:31:16:
      No instance for (RealFrac Int)
        arising from a use of `round'
      Possible fix: add an instance declaration for (RealFrac Int)
      In the expression: round (2 ** idx)
      In an equation for `mult': mult = round (2 ** idx)
      In an equation for `probIndex':
          probIndex idx xs
            = xs !! idx + mult
            where
                mult = round (2 ** idx)
  
  bn.hs:31:23:
      No instance for (Floating Int)
        arising from a use of `**'
      Possible fix: add an instance declaration for (Floating Int)
      In the first argument of `round', namely `(2 ** idx)'
      In the expression: round (2 ** idx)
      In an equation for `mult': mult = round (2 ** idx)
  Failed, modules loaded: none.
  Prelude&gt; 
  </code></pre>
  
  <p>Why does it occur? <code>2**idx</code> returns float, but <code>round</code> converts it to integer, so everything is an integer. Where do those "<code>Floating</code>" and "<code>RealFrac</code>" come from?</p>