bug report: compoundnf
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Fri Aug 22 12:47:01 GMT 2025
On 22/08/25 04:12, Paul Zimmermann wrote:
> Hi,
>
> $ cat test_compoundn_glibc.c
> #include <stdio.h>
> #include <math.h>
>
> extern float compoundnf (float, unsigned long long);
>
> int main()
> {
> float x = 0x1.d0004cp-32f;
> unsigned long long y = 5263617841566842879ull;
> float z = compoundnf (x, y);
> printf ("x=%a y=%llu z=%a\n", x, y, z);
> }
>
> # with glibc 2.42
> $ gcc test_compoundn_glibc.c -lm
> $ $BUILD/testrun.sh ./a.out
> x=0x1.d0004cp-32 y=5263617841566842879 z=-nan
>
> The expected result is +Inf.
>
> Paul
>
Hi Paul,
It seems indeed a bug, adding the testcase on auto-libm-test-in:
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index eee7df4653..a110db1fbf 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -4939,6 +4939,8 @@ compoundn -0x1.000002p-12 0x7654
compoundn 0x1.000002p-12 -0x7654
compoundn -0x1.000002p-12 -0x7654
+compoundn 0x1.d0004cp-32 5263617841566842879
+
cos 0
cos -0
cos pi/3
diff --git a/math/auto-libm-test-out-compoundn b/math/auto-libm-test-out-compoundn
index 62e8b1dadd..8bb6f15ad2 100644
--- a/math/auto-libm-test-out-compoundn
+++ b/math/auto-libm-test-out-compoundn
@@ -10243,3 +10243,28 @@ compoundn -0x1.000002p-12 -0x7654
= compoundn tonearest ibm128 -0x1.000002p-12 -30292LL : 0x6.5e1fd908d7c78fadcd0318c3dap+8 : inexact-ok
= compoundn towardzero ibm128 -0x1.000002p-12 -30292LL : 0x6.5e1fd908d7c78fadcd0318c3d8p+8 : inexact-ok
= compoundn upward ibm128 -0x1.000002p-12 -30292LL : 0x6.5e1fd908d7c78fadcd0318c3dap+8 : inexact-ok
+compoundn 0x1.d0004cp-32 5263617841566842879
+= compoundn downward binary32 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffp+124 : inexact-ok overflow errno-erange-ok
+= compoundn tonearest binary32 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero binary32 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffp+124 : inexact-ok overflow errno-erange-ok
+= compoundn upward binary32 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn downward binary64 0x1.d0004cp-32 5263617841566842879LL : 0xf.ffffffffffff8p+1020 : inexact-ok overflow errno-erange-ok
+= compoundn tonearest binary64 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero binary64 0x1.d0004cp-32 5263617841566842879LL : 0xf.ffffffffffff8p+1020 : inexact-ok overflow errno-erange-ok
+= compoundn upward binary64 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn downward intel96 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffp+16380 : inexact-ok overflow errno-erange-ok
+= compoundn tonearest intel96 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero intel96 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffp+16380 : inexact-ok overflow errno-erange-ok
+= compoundn upward intel96 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn downward m68k96 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffp+16380 : inexact-ok overflow errno-erange-ok
+= compoundn tonearest m68k96 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero m68k96 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffp+16380 : inexact-ok overflow errno-erange-ok
+= compoundn upward m68k96 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn downward binary128 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffffffffffffff8p+16380 : inexact-ok overflow errno-erange-ok
+= compoundn tonearest binary128 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero binary128 0x1.d0004cp-32 5263617841566842879LL : 0xf.fffffffffffffffffffffffffff8p+16380 : inexact-ok overflow errno-erange-ok
+= compoundn upward binary128 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn downward ibm128 0x1.d0004cp-32 5263617841566842879LL : 0xf.ffffffffffffbffffffffffffcp+1020 : xfail:ibm128-libgcc inexact-ok overflow errno-erange-ok
+= compoundn tonearest ibm128 0x1.d0004cp-32 5263617841566842879LL : plus_infty : inexact-ok overflow errno-erange
+= compoundn towardzero ibm128 0x1.d0004cp-32 5263617841566842879LL : 0xf.ffffffffffffbffffffffffffcp+1020 : xfail:ibm128-libgcc inexact-ok overflow errno-erange-ok
+= compoundn upward ibm128 0x1.d0004cp-32 5263617841566842879LL : plus_infty : xfail:ibm128-libgcc inexact-ok overflow errno-erange
I see:
$ math/test-float-compoundn
testing float (without inline functions)
Failure: compoundn (0x1.d0004cp-32, 5263617841566842879LL): Exception "Invalid operation" set
Failure: compoundn (0x1.d0004cp-32, 5263617841566842879LL): Exception "Underflow" set
Failure: Test: compoundn (0x1.d0004cp-32, 5263617841566842879LL)
Result:
is: qNaN
should be: inf inf
Failure: compoundn_downward (0x1.d0004cp-32, 5263617841566842879LL): Exception "Invalid operation" set
Failure: compoundn_downward (0x1.d0004cp-32, 5263617841566842879LL): Exception "Underflow" set
Failure: Test: compoundn_downward (0x1.d0004cp-32, 5263617841566842879LL)
Result:
is: qNaN
should be: 3.40282346e+38 0x1.fffffep+127
Failure: compoundn_towardzero (0x1.d0004cp-32, 5263617841566842879LL): Exception "Invalid operation" set
Failure: compoundn_towardzero (0x1.d0004cp-32, 5263617841566842879LL): Exception "Underflow" set
Failure: Test: compoundn_towardzero (0x1.d0004cp-32, 5263617841566842879LL)
Result:
is: qNaN
should be: 3.40282346e+38 0x1.fffffep+127
Failure: compoundn_upward (0x1.d0004cp-32, 5263617841566842879LL): Exception "Invalid operation" set
Failure: compoundn_upward (0x1.d0004cp-32, 5263617841566842879LL): Exception "Underflow" set
Failure: Test: compoundn_upward (0x1.d0004cp-32, 5263617841566842879LL)
Result:
is: qNaN
should be: inf inf
Test suite completed:
Maximum error found of `2' ulp
4 max error test cases,
1132 input tests,
- with 4576 tests for exception flags,
- with 866 tests for errno executed.
12 errors occurred.
Could you open a bug report to track this?
More information about the Libc-alpha
mailing list