Skip to content

Commit ccaea63

Browse files
committed
feat: add case for x == 0.0
--- 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 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 29debaa commit ccaea63

File tree

2 files changed

+10
-1
lines changed
  • lib/node_modules/@stdlib/math/base/special/exp2f

2 files changed

+10
-1
lines changed

lib/node_modules/@stdlib/math/base/special/exp2f/lib/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ var polyvalQ = require( './polyval_q.js' );
7474
*
7575
* | arithmetic | domain | # trials | peak | rms |
7676
* |:----------:|:-----------:|:--------:|:-------:|:-------:|
77-
* | IEEE | -127,+127 | 100000 | 1.7e-7 | 2.8e-8 |
77+
* | IEEE | -127,+127 | 100000 | 1.7e-7 | 2.8e-8 |
7878
*
7979
* @param {number} x - input value
8080
* @returns {number} function value
@@ -109,6 +109,10 @@ function exp2f( x ) {
109109
return 0.0;
110110
}
111111

112+
if ( x === 0.0 ) {
113+
return 1.0;
114+
}
115+
112116
// Separate into integer and fractional parts...
113117
n = float64ToFloat32( roundf( x ) );
114118
x -= float64ToFloat32( n );

lib/node_modules/@stdlib/math/base/special/exp2f/src/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ float stdlib_base_exp2f( const float x ) {
132132
return 0.0f;
133133
}
134134

135+
// Range reduction
136+
if( x == 0.0f ) {
137+
return 1.0f;
138+
}
139+
135140
// Separate into integer and fractional parts...
136141
n = stdlib_base_roundf( x );
137142
ax = x - n;

0 commit comments

Comments
 (0)