complex division is inaccurate
Bug #1266571 reported by
Michael Hudson-Doyle
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Linaro GCC |
Won't Fix
|
Undecided
|
Unassigned | ||
gcc |
In Progress
|
Medium
|
Bug Description
Hi, it seems details in the rounding of complex division are wrong:
ubuntu@arm64:~$ cat cplx.c
#include <stdio.h>
int main(int argc, char** argv)
{
__complex double c = 1.0 + 3.0i;
printf("%g\n", __imag__ (c/c));
}
ubuntu@arm64:~$ gcc cplx.c -o cplx
ubuntu@arm64:~$ ./cplx
-1.66533e-17
This happens with 4.8 and 4.9 (as of a couple of weeks ago).
Changed in gcc-linaro: | |
status: | New → Won't Fix |
Changed in gcc: | |
importance: | Unknown → Medium |
status: | Unknown → New |
Changed in gcc: | |
status: | New → Confirmed |
Changed in gcc: | |
status: | Confirmed → In Progress |
To post a comment you must log in.
This is because libgcc2.c is compiled in a way that lets the compiler used fused multiply add instructions. It shouldn't be!
(in this particular case, it's because if x is the closest float64 to 1/3, evaluating "3*x - 1" using fnmsub does not yield 0 because of the lack of intermediate rounding. Evaluating 3*x, rounding it, and then subtracting 1 does yield 0).