#4381: scaleFloat does not handle overflow correctly.
---------------------------------+------------------------------------------
    Reporter:  draconx           |        Owner:  daniel.is.fischer          
        Type:  bug               |       Status:  new                        
    Priority:  normal            |    Milestone:                             
   Component:  libraries/base    |      Version:  6.12.3                     
    Keywords:                    |     Testcase:                             
   Blockedby:                    |   Difficulty:                             
          Os:  Unknown/Multiple  |     Blocking:                             
Architecture:  Unknown/Multiple  |      Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------
Changes (by daniel.is.fischer):

  * owner:  => daniel.is.fischer


Comment:

 I can't reproduce precisely that, so I believe it's a 64-bit overflow,
 `encodeFloat` using 32-bit C-ints:
 {{{
 Prelude> decodeFloat (1 :: Double)
 (4503599627370496,-52)
 Prelude Data.Int> fromIntegral ((maxBound :: Int64) - 52) :: Int
 -53
 }}}
 However,
 {{{
 Prelude Data.Int> scaleFloat minBound 1
 Infinity
 }}}
 and I suspect that would evaluate to 1 on a 64-bit platform.

 Easy enough to fix, though it'll cost a little speed. Just clamp the
 scaling factor between say -3000 and +3000.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4381#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