#4867: Incorrect result from trig functions
---------------------------------+------------------------------------------
    Reporter:  gwright           |       Owner:                             
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  Compiler                   
     Version:  7.0.1             |    Keywords:                             
    Testcase:                    |   Blockedby:                             
          Os:  Unknown/Multiple  |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------
 Trigonometric functions give the wrong answer in some cases.  I have
 verified this bug on ghc-7.0.1 and ghc-7.0.1-rc1 on OS X 10.6 64 bit.
 (The bug may be limited to 64 bit platforms; I've not been able to
 reproduce it on ghc-6.10.4/OS X 10.5/32 bit.)

 Here's an example (ghc-7.0.2-rc1, OS X 10.6, 64 bit):
 {{{
 plumbbob-franklin> inplace/bin/ghc-stage2 --interactive
 GHCi, version 7.0.1.20101221: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package ffi-1.0 ... linking ... done.
 Prelude> tan (0.5 * pi + 0.01)
 -4.563974029425858e214
 Prelude> tan (0.5 * pi - 0.01)
 99.99666664444354
 Prelude>
 }}}
 The first result (`tan (0.5 * pi + 0.01)`) is wrong. The correct answer is
 close to -100.0.  The `sin` and `cos` functions also give incorrect
 answers in some cases, e.g.,
 {{{
 Prelude> cos (3.0 * pi)
 -3.666940035476786e76
 }}}

 At first glance, the bug seems related to the normalization of the
 argument (i.e., mapping the argument to the range `(-pi/2, pi/2)`).

 This is a nasty one. It ought to be fixed before 7.0.2 goes out.

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