From 787c104a2730d524f0efad7358c267584b348d5e Mon Sep 17 00:00:00 2001 From: MANDEep22332 Date: Wed, 22 Apr 2026 12:15:40 +0000 Subject: [PATCH 1/5] ulp-based-testing --- .../math/base/special/binomcoeff/test/test.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js index 16e87d20306d..6b28264eb9ad 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js @@ -22,8 +22,7 @@ var tape = require( 'tape' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var absf = require( '@stdlib/math/base/special/absf' ); -var EPS = require( '@stdlib/constants/float32/eps' ); +var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var binomcoeff = require( './../lib' ); @@ -54,8 +53,6 @@ tape( 'the function returns `NaN` if provided `NaN` for any parameter', function tape( 'the function evaluates the binomial coefficient for integers `n` and `k`', function test( t ) { var expected; - var delta; - var tol; var n; var k; var v; @@ -71,11 +68,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' t.strictEqual( v, expected[ i ], 'returns expected value' ); continue; } - delta = absf( v - expected[ i ] ); - - // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. - tol = 1.25 * EPS * absf( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. n: ' + n[ i ] + '. k: ' + k[ i ] + '. actual: ' + v + '. expected: ' + expected[ i ] + '. tol: ' + tol + '. Δ: ' + delta + '.' ); + t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value'); } t.end(); }); @@ -93,7 +86,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k` for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); - t.strictEqual( v, expected[ i ], 'returns expected value. actual: '+v+'. expected: '+expected[i]+'. n: '+n[i]+'. k: '+k[i]+'.' ); + t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); From 9f33b17e5ede6f2c3e3bbfd71c0e5bb677e7203f Mon Sep 17 00:00:00 2001 From: MANDEep22332 Date: Fri, 24 Apr 2026 04:14:21 +0000 Subject: [PATCH 2/5] fixing the error --- .../@stdlib/math/base/special/binomcoeff/test/test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js index 6b28264eb9ad..d62ddcfcebfe 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js @@ -68,7 +68,8 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' t.strictEqual( v, expected[ i ], 'returns expected value' ); continue; } - t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value'); + // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. + t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); }); @@ -86,7 +87,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k` for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); - t.strictEqual(isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); + t.strictEqual( v, expected[ i ], 'returns expected value' ); } t.end(); }); From 08a9fb8e4c5cf28dce653d4736b26b76266cf391 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Apr 2026 05:17:03 -0700 Subject: [PATCH 3/5] test: remove unnecessary condition Signed-off-by: Athan --- .../@stdlib/math/base/special/binomcoeff/test/test.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js index d62ddcfcebfe..fb6b915e66dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js @@ -64,11 +64,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); - if ( expected[ i ] === v ) { - t.strictEqual( v, expected[ i ], 'returns expected value' ); - continue; - } - // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. + =// NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); From ff33411c65523e451e143fd9877abe05a1942600 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Apr 2026 05:17:33 -0700 Subject: [PATCH 4/5] test: fix stray equal sign Signed-off-by: Athan --- .../@stdlib/math/base/special/binomcoeff/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js index fb6b915e66dc..cf2d0420ef70 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js @@ -64,7 +64,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); - =// NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. + // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); } t.end(); From cb087b9068262f99c34fa3601b461f3cb42e3e98 Mon Sep 17 00:00:00 2001 From: Athan Date: Sun, 26 Apr 2026 05:20:53 -0700 Subject: [PATCH 5/5] style: resolve lint error Signed-off-by: Athan --- .../@stdlib/math/base/special/binomcoeff/test/test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js index cf2d0420ef70..38f075b60dd1 100644 --- a/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/binomcoeff/test/test.js @@ -64,6 +64,7 @@ tape( 'the function evaluates the binomial coefficient for integers `n` and `k`' for ( i = 0; i < n.length; i++ ) { v = binomcoeff( n[ i ], k[ i ] ); expected[ i ] = float64ToFloat32( expected[ i ] ); + // NOTE: Exact comparison fails for large values due to single-precision floating-point rounding errors when intermediate results exceed the maximum safe integer for a 32-bit float. t.strictEqual( isAlmostSameValue( v, expected[ i ], 2 ), true, 'returns expected value' ); }