#2306: The (^) operator sometimes uses one (*) more than needed.
---------------------+------------------------------------------------------
 Reporter:  guest    |          Owner:  igloo  
     Type:  bug      |         Status:  closed 
 Priority:  normal   |      Milestone:  6.8.3  
Component:  Prelude  |        Version:  6.8.2  
 Severity:  minor    |     Resolution:  fixed  
 Keywords:           |     Difficulty:  Unknown
 Testcase:           |   Architecture:  Unknown
       Os:  Unknown  |  
---------------------+------------------------------------------------------
Changes (by igloo):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 It's now
 {{{
 (^) :: (Num a, Integral b) => a -> b -> a
 x0 ^ y0 | y0 < 0    = error "Negative exponent"
         | y0 == 0   = 1
         | otherwise = f x0 y0
     where -- f : x0 ^ y0 = x ^ y
           f x y | even y    = f (x * x) (y `quot` 2)
                 | y == 1    = x
                 | otherwise = g (x * x) ((y - 1) `quot` 2) x
           -- g : x0 ^ y0 = (x ^ y) * z
           g x y z | even y = g (x * x) (y `quot` 2) z
                   | y == 1 = x * z
                   | otherwise = g (x * x) ((y - 1) `quot` 2) (x * z)
 }}}
 in the HEAD and 6.8 branch.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2306#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to