[Python-Dev] Test_coercion failing on Panther for complex numbers
Tim Peters
tim.one@comcast.net
Tue, 22 Jul 2003 18:00:35 -0400
[Jack Jansen]
> Ah... Long ago in a universe far from here... I remember, I had the
> same problem on MacOS9 at some point.
And I believed it was a design error in the FPU's fused multiply-add
implementation.
> But the strange thing with the current incarnation of the problem is
> that the exact same binary (build on OSX 10.2) passes test_coercion on
> 10.2 but fails it on 10.3. Could the C library be involved?
Absolutely. This is how a string gets created from a complex:
PyOS_snprintf(buf, bufsz, "(%.*g%+.*gj)",
precision, v->cval.real,
precision, v->cval.imag);
IOW, the C library produces the "+" or "-" here, and C libraries are utterly
inconsistent about whether they print -0.0 with a "+" or a "-" sign. I
believe it's an FPU bug that -0.0 occurs in this test, but there are too
many accidents to be worth the pain of fighting here, and the test should be
rewritten not to produce these ambiguous (in practice although not in
theory) cases to begin with (but after 2.3).