From 2634f531694b3d215400fca0d483bfb7e1206758 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 30 Sep 2026 00:36:02 +0530 Subject: [PATCH] fix: preserve sign when rounding the smallest subnormal in round2 --- 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/round2/lib/main.js | 2 +- .../@stdlib/math/base/special/round2/test/test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round2/lib/main.js b/lib/node_modules/@stdlib/math/base/special/round2/lib/main.js index cfc5d6b8c659..038eeffdd2f8 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/round2/lib/main.js @@ -85,7 +85,7 @@ function round2( x ) { // If provided the smallest subnormal, no rounding possible: if ( p === MIN_EXP_SUBNORMAL ) { - return x; + return sign * x; } // Find the previous and next integer powers: diff --git a/lib/node_modules/@stdlib/math/base/special/round2/test/test.js b/lib/node_modules/@stdlib/math/base/special/round2/test/test.js index 8d9f587506be..c54a94070fde 100644 --- a/lib/node_modules/@stdlib/math/base/special/round2/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/round2/test/test.js @@ -82,6 +82,12 @@ tape( 'the function returns the minimum double-precision floating-point value if t.end(); }); +tape( 'the function returns the negative minimum double-precision floating-point value if provided the negative minimum double-precision floating-point value', function test( t ) { + var v = round2( -SMALLEST_SUBNORMAL ); + t.strictEqual( v, -SMALLEST_SUBNORMAL, 'returns negative smallest subnormal' ); + t.end(); +}); + tape( 'the function overflows if provided a sufficiently large value', function test( t ) { var x; var v;