Bug 473974 - cos() returns incorrect value in FE_UPWARD rounding mode
cos() returns incorrect value in FE_UPWARD rounding mode
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Linux
low Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2008-12-01 12:08 EST by Alexander Kruppa
Modified: 2008-12-01 20:35 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-12-01 20:35:40 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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

  None (edit)
Description Alexander Kruppa 2008-12-01 12:08:52 EST
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:

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 12:18:34 EST
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-01 20:35:40 EST
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.