#14933: atan2 returns wrong result in some case
-----------------------+------------------------------
Reporter: hanya | Owner: nobody
Type: bug | Status: new
Priority: normal | Milestone: Unscheduled
Component: - General | Version: R1/Development
Keywords: | Blocked By:
Blocking: | Has a Patch: 0
Platform: x86-64 |
-----------------------+------------------------------
atan2 C function returns wrong result in the following case.
{{{
// atan2.c
#include <math.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
// from Python/Lib/test/cmath_testcases.txt acos0200
// acos0200 acos 1.6206860518683021e+308 1.0308426226285283e+308 ->
// 0.56650826093826223 -710.54206874241561
double real = 1.6206860518683021e+308;
double imag = 1.0308426226285283e+308;
double r = atan2(imag, real); // real part
printf("expected: 0.56650826093826223\n");
printf(" result: %1.17lf\n", r);
//x86_64, result: 0.08332244049906361
}
// gcc -o atan2 atan2.c -g -O0
}}}
Python contains some test cases for its complex calculations.
It contains near infinity acos0200 test executed by test_cmath.
The test can be executed as follows:
{{{
python -m test test_cmath
}}}
The same calculation in the Python interactive:
{{{
(0.08332244049906361-710.5420687424156j)import cmath
c = complex(1.6206860518683021e+308, 1.0308426226285283e+308)
cmath.acos(c)