Bug 473974 - cos() returns incorrect value in FE_UPWARD rounding mode
Summary: cos() returns incorrect value in FE_UPWARD rounding mode
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 9
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-01 17:08 UTC by Alexander Kruppa
Modified: 2008-12-02 01:35 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2008-12-02 01:35:40 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Test case for incorrect value of cos() (290 bytes, text/plain)
2008-12-01 17:08 UTC, Alexander Kruppa
no flags Details

Description Alexander Kruppa 2008-12-01 17:08:52 UTC
Created attachment 325265 [details]
Test case for incorrect value of cos()

Description of problem:
The attached test case produces the erroneous value of -20763584.029346 for
cos(Pi / 2) when the rounding mode is set to FE_UPWARD, instead of the
correct value (close to) 0. Other rounding modes do not show this error,
compiling with optimization enabled (-O1, -O2 or -O3) or as a 32 bit binary
with -m32 also do not show the error. If the binary is linked statically with
-static, the bug disappears as well.


Version-Release number of selected component (if applicable):

gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
glibc-2.8-8.x86_64 (Build Date: Thu Jul 17 00:31:06 2008)


How reproducible:

Steps to Reproduce:
1.Compile attached test case with
gcc -O0 -o cos_bug cos_bug.c -lm

2. run "./cos_bug"

  
Actual results:

Prints 
x = 1.57079632679489655800 = 0x1.921fb54442d18p+0
cos(x) = -20763584.029346


Expected results:

cos(x) should be a value close to 0.


Additional info:

Processor is Intel(R) Core(TM)2 CPU 6400  @ 2.13GHz.

May be related to bug #88513

Comment 1 Jakub Jelinek 2008-12-01 17:18:34 UTC
These routines aren't supposed to be called in non-standard rounding mode.
That's the caller's fault.

Comment 2 Ulrich Drepper 2008-12-02 01:35:40 UTC
What Jakub said.  The routines can only be called in the default mode.  Programs changing the mode have to (temporarily) change it back before calling into the library.


Note You need to log in before you can comment on or make changes to this bug.