From 9b2e6b4afa8b14abac5de1f11c3af3e3bfea1e77 Mon Sep 17 00:00:00 2001 From: 0PrashantYadav0 Date: Mon, 19 Oct 2026 17:41:05 +0530 Subject: [PATCH] fix: return correct value for `x = -0.5` in `math/base/special/acosf` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/acosf/lib/main.js | 2 +- .../@stdlib/math/base/special/acosf/test/test.js | 6 ++++++ .../@stdlib/math/base/special/acosf/test/test.native.js | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/acosf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/acosf/lib/main.js index 0fb76378ac31..1a8afefabefe 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/acosf/lib/main.js @@ -111,7 +111,7 @@ function acosf( x ) { r = float64ToFloat32( p / q ); return float64ToFloat32( PIO2_HI - float64ToFloat32( x - float64ToFloat32( PIO2_LO - float64ToFloat32( x * r ) ) ) ); // eslint-disable-line max-len } - if ( x < -0.5 ) { + if ( x <= -0.5 ) { z = float64ToFloat32( 0.5 * float64ToFloat32( 1.0 + x ) ); p = float64ToFloat32( z * polyp( z ) ); q = float64ToFloat32( 1.0 + float64ToFloat32( z * QS1 ) ); diff --git a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js index 371b9914a37d..aa74e1d3f16b 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.js @@ -140,6 +140,12 @@ tape( 'the function returns `PI` if provided a value equal to `-1`', function te t.end(); }); +tape( 'the function returns `2π/3` if provided `-0.5`', function test( t ) { + var v = acosf( -0.5 ); + t.strictEqual( v, float64ToFloat32( 2.0 * PI / 3.0 ), 'returns expected value' ); + t.end(); +}); + tape( 'the function returns `0` if provided `1`', function test( t ) { t.strictEqual( isPositiveZero( acosf( 1.0 ) ), true, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js index 013d6750b464..26b08194ce35 100644 --- a/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/acosf/test/test.native.js @@ -149,6 +149,12 @@ tape( 'the function returns `PI` if provided a value equal to `-1`', opts, funct t.end(); }); +tape( 'the function returns `2π/3` if provided `-0.5`', opts, function test( t ) { + var v = acosf( -0.5 ); + t.strictEqual( v, float64ToFloat32( 2.0 * PI / 3.0 ), 'returns expected value' ); + t.end(); +}); + tape( 'the function returns `0` if provided `1`', opts, function test( t ) { t.strictEqual( isPositiveZero( acosf( 1.0 ) ), true, 'returns expected value' ); t.end();