#4867: ghci displays negative floats incorrectly (was: Incorrect result from 
trig
functions)
-------------------------------+--------------------------------------------
    Reporter:  gwright         |        Owner:  gwright                    
        Type:  bug             |       Status:  new                        
    Priority:  high            |    Milestone:  7.0.2                      
   Component:  GHCi            |      Version:  7.0.1                      
    Keywords:                  |     Testcase:                             
   Blockedby:                  |   Difficulty:                             
          Os:  MacOS X         |     Blocking:                             
Architecture:  x86_64 (amd64)  |      Failure:  Incorrect result at runtime
-------------------------------+--------------------------------------------

Comment(by gwright):

 Replying to [comment:26 altaic]:
 > Not sure if you had already discovered this, but it appears the bug is
 limited to `Double`, while `Float` appears to be fine:
 > {{{
 > Prelude> -1.0 :: Float
 > -1.0
 > Prelude> -1.0 :: Double
 > -3.666940035476786e76
 > }}}
 >
 > Oddly, the transform that's producing the garbage value is reversible
 (guessing there'd be loss of bits at extremes):
 > {{{
 > Prelude> -1.0 :: Double
 > -3.666940035476786e76
 > Prelude> -3.666940035476786e76 :: Double
 > -1.0
 > }}}

 I don't think I noticed the `Float`/`Double` difference earlier but with
 the latest linker patch everything seems OK.  I'll check again to verify
 this.

 The failed relocations caused garbage values to be printed by `ghci`, but
 the intermediate values in the calcuations are OK.  The error went like
 this:  when a negative `Double` is printed, a '-' sign is printed, then
 the negative of the value is printed.  IEEE 754 doubles are negated by
 `xor`-ing them with a fixed bitmask, which complements the sign bit.  The
 problem was that the relocation to the bitmask was wrong, so the double
 was `xor`-ed with a constant, incorrect mask.

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