#2059: Erroneous results in trigonometric functions for > double-precision
values
-------------------------------+--------------------------------------------
Reporter: daniel.is.fischer | Owner: igloo
Type: bug | Status: new
Priority: normal | Milestone: 6.8.3
Component: Compiler | Version: 6.8.1
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: x86
Os: Linux |
-------------------------------+--------------------------------------------
Comment (by igloo):
OK, the problem is that the `fsin` instruction (and, I assume, its
friends) only take arguments with absolute value `<= 2^63`. The reason it
works in C is that they look to see if the out-of-range flag is set when
they call it, and if so take the sine of the remainder after dividing by
`2 * pi` (only it's slightly more complicated, as they really take the
partial remainder, which means they might have to do it multiple times):
{{{
0xf7f810f0 <sin+0>: fldl 0x4(%esp)
0xf7f810f4 <sin+4>: fsin
0xf7f810f6 <sin+6>: fnstsw %ax
0xf7f810f8 <sin+8>: test $0x400,%eax
0xf7f810fd <sin+13>: jne 0xf7f81100 <sin+16>
0xf7f810ff <sin+15>: ret
0xf7f81100 <sin+16>: fldpi
0xf7f81102 <sin+18>: fadd %st(0),%st
0xf7f81104 <sin+20>: fxch %st(1)
0xf7f81106 <sin+22>: fprem1
0xf7f81108 <sin+24>: fnstsw %ax
0xf7f8110a <sin+26>: test $0x400,%eax
0xf7f8110f <sin+31>: jne 0xf7f81106 <sin+22>
0xf7f81111 <sin+33>: fstp %st(1)
0xf7f81113 <sin+35>: fsin
0xf7f81115 <sin+37>: ret
}}}
I guess we should do the same.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2059#comment:8>
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