Skip to content

Commit 932727f

Browse files
committed
fix: fix some minor issues
1. Removed the unnecessary note from README. Because f32(1e-44) = 9.809e-45 which is not a power of 10 — it's just the nearest float32 value (7 * 2^-149). Truncating it to 1.401e-45 (10^-45) 2. Remove the unnecessary test case. 3. Put a f32 wrapper around the return computation in main.js 4. Put f after floating number in main.c and readme.md --- 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: passed - 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4afa586 commit 932727f

4 files changed

Lines changed: 4 additions & 24 deletions

File tree

lib/node_modules/@stdlib/math/base/special/trunc10f/README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,6 @@ v = trunc10f( NaN );
7878

7979
<section class="notes">
8080

81-
## Notes
82-
83-
- The function may not return accurate results for subnormals due to a general loss in precision.
84-
85-
```javascript
86-
var v = trunc10f( 1.0e-46 ); // should return 1.0e-46
87-
// returns 0.0
88-
```
89-
9081
</section>
9182

9283
<!-- /.notes -->
@@ -145,7 +136,7 @@ logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, trunc10f );
145136
Rounds a `single-precision` floating point number to the nearest power of `10` toward zero.
146137

147138
```c
148-
float y = stdlib_base_trunc10f( -4.2 );
139+
float y = stdlib_base_trunc10f( -4.2f );
149140
// returns -1.0
150141
```
151142

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function trunc10f( x ) {
6767
} else {
6868
sign = ONE;
6969
}
70-
return sign * powf( TEN, floorf( f32( log10( x ) ) ) );
70+
return f32( sign * powf( TEN, floorf( f32( log10( x ) ) ) ) );
7171
}
7272

7373

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @return rounded value
3131
*
3232
* @example
33-
* float y = stdlib_base_trunc10f( 13.0 );
33+
* float y = stdlib_base_trunc10f( 13.0f );
3434
* // returns 10.0
3535
*/
3636
float stdlib_base_trunc10f( const float x ) {
@@ -47,5 +47,5 @@ float stdlib_base_trunc10f( const float x ) {
4747
} else {
4848
sign = 1.0f;
4949
}
50-
return sign * stdlib_base_powf( 10.0f, stdlib_base_floorf( stdlib_base_log10( xc ) ) );
50+
return sign * stdlib_base_powf( 10.0f, stdlib_base_floorf( (float)stdlib_base_log10( xc ) ) );
5151
}

lib/node_modules/@stdlib/math/base/special/trunc10f/test/test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,6 @@ tape( 'the function supports rounding subnormal values', function test( t ) {
125125
t.end();
126126
});
127127

128-
tape( 'the function may return incorrect results for small subnormals', function test( t ) {
129-
var x;
130-
var v;
131-
132-
x = powf( 10.0, -44 );
133-
v = trunc10f( x );
134-
t.notEqual( v, x, 'should return input value but does not due to loss in precision' );
135-
136-
t.end();
137-
});
138-
139128
tape( 'the function rounds a single-precision floating point number to the nearest power of 10 toward zero', function test( t ) {
140129
t.strictEqual( trunc10f( -4.2 ), -1.0, 'returns expected value' );
141130
t.strictEqual( trunc10f( -4.5 ), -1.0, 'returns expected value' );

0 commit comments

Comments
 (0)