![]() |
|
Message-ID: <CABqyc3weC5TM9iptA1_wdjcnt1kO6QH_c3HE=L9v3kQfbSyfhQ@mail.gmail.com> Date: Tue, 11 Mar 2025 12:30:58 +0100 From: Victor Stinner <vstinner@...hon.org> To: musl@...ts.openwall.com Subject: Bug in fma(): should return negative zero Hi, test_math.test_fma_zero_result() of Python 3.13 fails when Python is built with musl: https://github.com/python/cpython/issues/131032 The problem is that fma() returns +0.0 instead of -0.0 on some tests. Example: --- #include <math.h> #include <stdio.h> int main(int argc, char **argv) { double tiny = 1e-300; double zero = 0.0; double result = fma(tiny, -tiny, zero); printf("fma(%+g, %+g, %+g) = %+g\n", tiny, -tiny, zero, result); return 0; } --- Output on Alpine with musl-1.2.5-r9: --- $ gcc x.c -Og -o x -lm && ./x fma(+1e-300, -1e-300, +0) = +0 --- Expected output: --- fma(+1e-300, -1e-300, +0) = -0 --- Last year, I reported a similar bug to FreeBSD which was fixed: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277783 Link to Python test_fma_zero_result(): https://github.com/python/cpython/blob/425e0af74fb882b95f81923123bd4afad0cda157/Lib/test/test_math.py#L2762-L2816 Tell me if you need more details. Victor -- Night gathers, and now my watch begins. It shall not end until my death.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.