From 0aa97031d86bfe9aa2d307c5af8e70fa0036fa8d Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 3 Jan 2026 20:35:43 +0000 Subject: [PATCH 01/22] feat: add math/base/special/round10f --- 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../math/base/special/round10f/README.md | 203 ++++++++++++++++++ .../special/round10f/benchmark/benchmark.js | 61 ++++++ .../round10f/benchmark/benchmark.native.js | 71 ++++++ .../round10f/benchmark/c/native/benchmark.c | 77 +++++++ .../math/base/special/round10f/docs/repl.txt | 31 +++ .../special/round10f/docs/types/index.d.ts | 47 ++++ .../base/special/round10f/docs/types/test.ts | 58 +++++ .../special/round10f/examples/c/example.c | 42 ++++ .../base/special/round10f/examples/index.js | 44 ++++ .../stdlib/math/base/special/round10f.h | 44 ++++ .../math/base/special/round10f/lib/index.js | 49 +++++ .../math/base/special/round10f/lib/main.js | 78 +++++++ .../math/base/special/round10f/lib/native.js | 53 +++++ .../math/base/special/round10f/package.json | 122 +++++++++++ .../math/base/special/round10f/src/addon.c | 22 ++ .../math/base/special/round10f/src/main.c | 60 ++++++ .../math/base/special/round10f/test/test.js | 83 +++++++ .../base/special/round10f/test/test.native.js | 116 ++++++++++ 18 files changed, 1261 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md new file mode 100644 index 000000000000..8ef60896ae32 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -0,0 +1,203 @@ + + +# round10f + +> Round a numeric value to the nearest multiple of \\(10^n\\) using single-precision floating-point arithmetic. + +
+ +## Usage + +```javascript +var round10f = require( '@stdlib/math/base/special/round10f' ); +``` + +#### round10f( v, n ) + +Rounds a numeric value to the nearest multiple of 10^n usingsingle-precision floating-point arithmetic. + +```javascript +var y; + +y = round10f( 3.1415926, -2 ); +// returns 1 + +y = round10f( 3.1415926, 0 ); +// returns 1 + +y = round10f( 123.456, 1 ); +// returns 100 + +y = round10f( -2.5, 0 ); +// returns -1 + +y = round10f( -0.0, 0 ); +// returns -0 +``` + +
+ + + +
+ +## Examples + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var round10f = require( '@stdlib/math/base/special/round10f' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = uniform( 100, -50.0, 50.0, opts ); + +// Ensure float32 precision: +var i; +for ( i = 0; i < x.length; i++ ) { + x[ i ] = toFloat32( x[ i ] ); +} + +var n = -1; + +function fcn( v ) { + return round10f( v, n ); +} + +logEachMap('x: %0.4f. Rounded: %0.4f.', x, fcn); +``` + +
+ + + + +* * * + +
+ +## C APIs + +
+ +This package provides a C API for rounding single-precision floating-point numbers to the nearest multiple of \\(10^n\\). + +
+ + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/round10f.h" +``` + +#### stdlib_base_round10f( x, n ) + +Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\). + +```c +float out = stdlib_base_round10f( 3.14f, 0 ); +// returns 3.0f + +out = stdlib_base_round10f( 3.14f, -1 ); +// returns 3.1f +``` + +**Arguments** + +- **x**: `[in] float` input value. +- **n**: `[in] int32_t` power of ten exponent. + +**Returns** + +- `float`: rounded value. + +```c +float stdlib_base_round10f( const float x, const int32_t n ); +``` + +
+ + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/round10f.h" +#include + +int main( void ) { + const float x[] = { + -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, + 0.56f, 1.67f, 2.78f, 3.89f, 5.0f + }; + const int n = -1; + + float v; + int i; + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_round10f( x[ i ], n ); + printf( "round10f(%f,%d) = %f\n", x[ i ], n, v ); + } +} +``` + +
+ + + +
+ + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js new file mode 100644 index 000000000000..3e2b55ea1b8a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var round10f = require( './../lib/main.js' ); +var pkg = require( './../package.json' ).name; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var exps; + var x; + var y; + var i; + + // Generate float32 input values: + x = uniform( 100, -5.0e3, 5.0e3 ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = toFloat32( x[ i ] ); + } + + exps = [ -3, -1, 0, 1, 3 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = round10f( x[ i % x.length ], exps[ i % exps.length ] ); + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + + if ( isnanf( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js new file mode 100644 index 000000000000..549f37eb6359 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var round10f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( round10f instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var exps; + var x; + var y; + var i; + + // Generate float32 input data: + x = uniform( 100, -5.0e3, 5.0e3 ); + for ( i = 0; i < x.length; i++ ) { + x[ i ] = toFloat32( x[ i ] ); + } + + exps = [ -3, -1, 0, 1, 3 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = round10f( x[ i % x.length ], exps[ i % exps.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..ec6895fb4bd3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/round10f.h" +#include +#include +#include +#include + +#define NAME "round10f" +#define ITERATIONS 1000000 +#define REPEATS 3 + +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +static float rand_float( void ) { + return (float)rand() / ( (float)RAND_MAX + 1.0f ); +} + +static double benchmark( void ) { + float x[100]; + const int exps[5] = { -3, -1, 0, 1, 3 }; + volatile float y; /* prevent optimization */ + double elapsed; + double t; + int i; + int n; + + for ( i = 0; i < 100; i++ ) { + x[i] = ( 1.0e4f * rand_float() ) - 5.0e3f; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + n = exps[ i % 5 ]; + y = stdlib_base_round10f( x[ i % 100 ], n ); + } + elapsed = tic() - t; + + if ( y != y ) { + printf( "should not return NaN\n" ); + } + + return elapsed; +} + +int main( void ) { + double elapsed; + int i; + + srand( time( NULL ) ); + + printf( "native::%s\n", NAME ); + for ( i = 0; i < REPEATS; i++ ) { + elapsed = benchmark(); + printf( " elapsed: %0.9f sec\n", elapsed ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt new file mode 100644 index 000000000000..ef90008ba090 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt @@ -0,0 +1,31 @@ +{{alias}}( x, n ) + Rounds a numeric value to the nearest multiple of 10^n using + single-precision floating-point arithmetic. + + Parameters + ---------- + x: number + Input value. + n: number + Integer power of 10 specifying the decimal place to which to round. + + Returns + ------- + y: number + Rounded value. + + Examples + -------- + > var y = {{alias}}( 3.1415926, -2 ) + 1 + > y = {{alias}}( 3.1415926, 0 ) + 1 + > y = {{alias}}( 123.456, 2 ) + 100.0 + > y = {{alias}}( -2.5, 0 ) + -1 + > y = {{alias}}( -0.0, 0 ) + -0.0 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts new file mode 100644 index 000000000000..91202c272d33 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/** +* Rounds a numeric value to the nearest power of 10 on a linear scale (single-precision). +* +* @param x - input value +* @param n - decimal exponent +* @returns rounded value +* +* @example +* var v = round10f( 3.1415926, 0 ); +* // returns 1 +* +* @example +* var v = round10f( 3.1415926, -1 ); +* // returns 1 +* +* @example +* var v = round10f( 123.0, 1 ); +* // returns 100 +* +* @example +* var v = round10f( NaN, 2 ); +* // returns NaN +*/ +declare function round10f( x: number, n: number ): number; + + +// EXPORTS // + +export = round10f; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts new file mode 100644 index 000000000000..9e9f06dd0722 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts @@ -0,0 +1,58 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import round10f = require( './index' ); + +// TESTS // + +// The function returns a number... +{ + round10f( 8.78, 2 ); // $ExpectType number + round10f( 8.78, 0 ); // $ExpectType number + round10f( 8.78, -2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument other than a number... +{ + round10f( true, 1 ); // $ExpectError + round10f( false, 1 ); // $ExpectError + round10f( null, 1 ); // $ExpectError + round10f( undefined, 1 ); // $ExpectError + round10f( '5', 1 ); // $ExpectError + round10f( [], 1 ); // $ExpectError + round10f( {}, 1 ); // $ExpectError + round10f( ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument other than a number... +{ + round10f( 3.14, true ); // $ExpectError + round10f( 3.14, false ); // $ExpectError + round10f( 3.14, null ); // $ExpectError + round10f( 3.14, undefined ); // $ExpectError + round10f( 3.14, '5' ); // $ExpectError + round10f( 3.14, [] ); // $ExpectError + round10f( 3.14, {} ); // $ExpectError + round10f( 3.14, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + round10f(); // $ExpectError + round10f( 3.14 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c new file mode 100644 index 000000000000..495e21078811 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/round10f.h" +#include + +int main( void ) { + const float x[] = { + -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, + 0.56f, 1.67f, 2.78f, 3.89f, 5.0f + }; + + /* Round to 0.1, 1, and 10: */ + const int exps[] = { -1, 0, 1 }; + + float v; + int i; + int j; + + for ( j = 0; j < 3; j++ ) { + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_round10f( x[ i ], exps[ j ] ); + printf( "round10f(%f,%d) = %f\n", x[ i ], exps[ j ], v ); + } + } + return 0; +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js new file mode 100644 index 000000000000..cf595322fbd5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var round10f = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = uniform( 100, -50.0, 50.0, opts ); + +// Ensure float32 precision: +var i; +for ( i = 0; i < x.length; i++ ) { + x[ i ] = toFloat32( x[ i ] ); +} + +var n = -1; + +function fcn( v ) { + return round10f( v, n ); +} + +logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, fcn ); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h new file mode 100644 index 000000000000..34938d3b98d6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_SPECIAL_ROUND10F_H +#define STDLIB_MATH_BASE_SPECIAL_ROUND10F_H + +/* +* If C++, prevent name mangling... +*/ +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* +* Rounds a single-precision floating-point number to the nearest multiple of `10^n`. +* +* @param x input value +* @param n integer power of 10 specifying the decimal place +* @return rounded value +*/ +float stdlib_base_round10f( const float x, const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js new file mode 100644 index 000000000000..77967d6bcb83 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Round a single-precision floating-point number to the nearest multiple of `10^n`. +* +* @module @stdlib/math/base/special/round10f +* +* @example +* var round10f = require( '@stdlib/math/base/special/round10f' ); +* +* var v = round10f( 3.1415926, 0 ); +* // returns 1 +* +* v = round10f( 3.1415926, -1 ); +* // returns 1 +* +* v = round10f( 123.45, 1 ); +* // returns 100 +* +* v = round10f( -2.5, 0 ); +* // returns -1 +*/ + +// MODULES // + +var round10f = require( './main.js' ); + + +// EXPORTS // + +module.exports = round10f; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js new file mode 100644 index 000000000000..9a00359e3506 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js @@ -0,0 +1,78 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isInfinitef = require( '@stdlib/math/base/assert/is-infinitef' ); +var floorf = require( '@stdlib/math/base/special/floorf' ); +var powf = require( '@stdlib/math/base/special/powf' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var log10 = require( '@stdlib/math/base/special/log10' ); + + +// MAIN // + +/** +* Rounds a numeric value to the nearest power of `10` on a linear scale (single-precision). +* +* @param {number} x - input value +* @returns {number} rounded value (float32) +*/ +function round10f( x ) { + var ax; + var e0; + var e1; + var y0; + var y1; + + // Force float32: + x = toFloat32( x ); + + // Handle specials: + if ( isnanf( x ) || isInfinitef( x ) || x === 0.0 ) { + return x; + } + + // Abs(x): + ax = toFloat32( abs( x ) ); + + // Lower exponent: + e0 = floorf( log10( ax ) ); + + // Next exponent: + e1 = e0 + 1; + + // Compute two powers: + y0 = powf( 10.0, e0 ); + y1 = powf( 10.0, e1 ); + + // Return whichever is closer: + if ( (ax - y0) <= (y1 - ax) ) { + return toFloat32( ( x < 0.0 ) ? -y0 : y0 ); + } + return toFloat32( ( x < 0.0 ) ? -y1 : y1 ); +} + + +// EXPORTS // + +module.exports = round10f; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js new file mode 100644 index 000000000000..96ba8fbdc6cf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Rounds a single-precision floating-point number to the nearest multiple of `10^n`. +* +* @private +* @param {number} x - input value +* @param {integer} n - integer power of 10 specifying the decimal place +* @returns {number} rounded value +* +* @example +* var v = round10f( 3.1415926, 0 ); +* // returns 3.0 +* +* v = round10f( 3.1415926, -1 ); +* // returns 3.1 +* +* v = round10f( 123.45, 1 ); +* // returns 120.0 +*/ +function round10f( x, n ) { + return addon( x, n ); +} + + +// EXPORTS // + +module.exports = round10f; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/package.json b/lib/node_modules/@stdlib/math/base/special/round10f/package.json new file mode 100644 index 000000000000..cff07ef9087e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/package.json @@ -0,0 +1,122 @@ +{ + "name": "@stdlib/math/base/special/round10f", + "version": "0.0.0", + "description": "Round a numeric value to the nearest power of 10 on a linear scale using single-precision floating-point arithmetic.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "math.round", + "round", + "round10", + "round10f", + "nearest", + "number", + "float32", + "single-precision" + ], + "__stdlib__": { + "scaffold": { + "$schema": "math/base/single@v1.0", + "base_alias": "round10f", + "alias": "round10f", + "pkg_desc": "round a numeric value to the nearest power of 10 on a linear scale using single-precision floating-point arithmetic", + "desc": "rounds a numeric value to the nearest power of ten on a linear scale using single-precision floating-point arithmetic", + "short_desc": "", + "parameters": [ + { + "name": "x", + "desc": "input value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + }, + "domain": [ + { + "min": "-infinity", + "max": "infinity" + } + ], + "rand": { + "prng": "random/base/uniform", + "parameters": [ + -10, + 10 + ] + } + } + ], + "returns": { + "desc": "function value", + "type": { + "javascript": "number", + "jsdoc": "number", + "c": "float", + "dtype": "float32" + } + }, + "keywords": [ + "round", + "round10", + "round10f", + "nearest" + ], + "extra_keywords": [ + "math.round", + "float32" + ] + } + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c new file mode 100644 index 000000000000..313f695db3b7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c @@ -0,0 +1,22 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/round10f.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_FI_F( stdlib_base_round10f ) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c new file mode 100644 index 000000000000..d0827e988add --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/round10f.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/assert/is_infinitef.h" +#include "stdlib/math/base/special/roundf.h" +#include "stdlib/math/base/special/powf.h" +#include "stdlib/number/float32/base/to_float32.h" +#include + +/** +* Rounds a single-precision floating-point number to the nearest multiple +* of `10^n` using round-to-nearest-even. +* +* @param x input value +* @param n integer power of 10 indicating the decimal place +* @return rounded value +*/ +float stdlib_base_round10f( const float x, const int32_t n ) { + float s; + float y; + + /* Propagate NaN and ±infinity: */ + if ( stdlib_base_is_nanf( x ) || stdlib_base_is_infinitef( x ) ) { + return x; + } + + /* Preserve sign of ±0.0: */ + if ( x == 0.0f ) { + return x; + } + + /* Scale by 10^(-n): */ + s = stdlib_base_powf( 10.0f, (float)(-n) ); + y = stdlib_base_to_float32( x * s ); + + /* Round (ties-to-even): */ + y = stdlib_base_roundf( y ); + + /* Scale back: */ + y = stdlib_base_to_float32( y / s ); + + return y; +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js new file mode 100644 index 000000000000..eed536cef5dd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var round10f = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof round10f, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var v = round10f( toFloat32( +0.0 ) ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v = round10f( toFloat32( -0.0 ) ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { + var v = round10f( NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { + var v = round10f( PINF ); + t.strictEqual( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) { + var v = round10f( NINF ); + t.strictEqual( v, NINF, 'returns -infinity' ); + t.end(); +}); + +tape( 'the function rounds to the nearest power of 10 on a linear scale', function test( t ) { + t.strictEqual( round10f( toFloat32( -4.2 ) ), toFloat32( -1.0 ), '-4.2 -> -1' ); + t.strictEqual( round10f( toFloat32( -4.8 ) ), toFloat32( -1.0 ), '-4.8 -> -1' ); + t.strictEqual( round10f( toFloat32( 4.2 ) ), toFloat32( 1.0 ), '4.2 -> 1' ); + t.strictEqual( round10f( toFloat32( 9.4 ) ), toFloat32( 10.0 ), '9.4 -> 10' ); + t.strictEqual( round10f( toFloat32( 9.5 ) ), toFloat32( 10.0 ), '9.5 -> 10' ); + t.strictEqual( round10f( toFloat32( 12.0 ) ), toFloat32( 10.0 ), '12 -> 10' ); + t.strictEqual( round10f( toFloat32( -12.0 ) ), toFloat32( -10.0 ), '-12 -> -10' ); + t.strictEqual( round10f( toFloat32( 60.1 ) ), toFloat32( 100.0 ), '60.1 -> 100' ); + t.strictEqual( round10f( toFloat32( 0.3 ) ), toFloat32( 0.1 ), '0.3 -> 0.1' ); + t.strictEqual( round10f( toFloat32( 0.61 ) ), toFloat32( 1.0 ), '0.61 -> 1' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js new file mode 100644 index 000000000000..5c33ba318bf0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// VARIABLES // + +var round10f = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( round10f instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof round10f, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { + var v = round10f( toFloat32( +0.0 ), 0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v = round10f( toFloat32( -0.0 ), 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v = round10f( NaN, 0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { + var v = round10f( PINF, 0 ); + t.strictEqual( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { + var v = round10f( NINF, 0 ); + t.strictEqual( v, NINF, 'returns -infinity' ); + t.end(); +}); + +tape( 'the function rounds to the nearest integer when n = 0', opts, function test( t ) { + t.strictEqual( round10f( 3.14, 0 ), 3.0, '3.14 -> 3' ); + t.strictEqual( round10f( 3.5, 0 ), 4.0, 'ties-to-even' ); + t.strictEqual( round10f( 2.5, 0 ), 2.0, 'ties-to-even' ); + t.strictEqual( round10f( -2.5, 0 ), -2.0, 'ties-to-even' ); + t.end(); +}); + +tape( 'the function rounds to the nearest tenth when n = -1', opts, function test( t ) { + t.strictEqual( round10f( 3.14, -1 ), toFloat32( 3.1 ), '3.14 -> 3.1' ); + t.strictEqual( round10f( 3.15, -1 ), toFloat32( 3.2 ), '3.15 -> 3.2' ); + t.end(); +}); + +tape( 'the function rounds to the nearest hundredth when n = -2', opts, function test( t ) { + t.strictEqual( round10f( 1.234, -2 ), toFloat32( 1.23 ), '1.234 -> 1.23' ); + t.strictEqual( round10f( 1.235, -2 ), toFloat32( 1.24 ), 'ties handled' ); + t.end(); +}); + +tape( 'the function rounds to the nearest 10 when n = 1', opts, function test( t ) { + t.strictEqual( round10f( 17.2, 1 ), 20.0, '17.2 -> 20' ); + t.strictEqual( round10f( 14.9, 1 ), 10.0, '14.9 -> 10' ); + t.end(); +}); + +tape( 'the function rounds to the nearest 100 when n = 2', opts, function test( t ) { + t.strictEqual( round10f( 249.0, 2 ), 200.0, '249 -> 200' ); + t.strictEqual( round10f( 250.0, 2 ), 300.0, 'ties-to-even' ); + t.end(); +}); + +tape( 'the function preserves signed zeros after rounding', opts, function test( t ) { + t.strictEqual( isPositiveZero( round10f( +0.04, -1 ) ), true, '+0 stays +0' ); + t.strictEqual( isNegativeZero( round10f( -0.04, -1 ) ), true, '-0 stays -0' ); + t.end(); +}); From f5a68eecca5bf138fc02bc90ef775bbf31846748 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:19:19 +0000 Subject: [PATCH 02/22] feat: add math/base/special/round10f --- 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: na - 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: 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 --- --- lib/node_modules/@stdlib/math/base/special/round10f/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index 8ef60896ae32..04bacaa0afae 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -30,7 +30,7 @@ limitations under the License. var round10f = require( '@stdlib/math/base/special/round10f' ); ``` -#### round10f( v, n ) +#### round10f( x, n ) Rounds a numeric value to the nearest multiple of 10^n usingsingle-precision floating-point arithmetic. @@ -82,7 +82,7 @@ for ( i = 0; i < x.length; i++ ) { var n = -1; function fcn( v ) { - return round10f( v, n ); + return round10f( v); } logEachMap('x: %0.4f. Rounded: %0.4f.', x, fcn); From 3fb5f69dea4c1911c9e8b466c50eebbe99c0bfeb Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:25:52 +0000 Subject: [PATCH 03/22] feat: add math/base/special/round10f --- 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: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../math/base/special/round10f/README.md | 4 +- .../special/round10f/benchmark/benchmark.js | 2 +- .../round10f/benchmark/benchmark.native.js | 2 +- .../round10f/benchmark/c/native/Makefile | 146 +++++++++++++++ .../round10f/benchmark/c/native/benchmark.c | 2 +- .../math/base/special/round10f/binding.gyp | 170 ++++++++++++++++++ .../special/round10f/docs/types/index.d.ts | 2 +- .../base/special/round10f/docs/types/test.ts | 2 +- .../base/special/round10f/examples/c/Makefile | 146 +++++++++++++++ .../special/round10f/examples/c/example.c | 2 +- .../base/special/round10f/examples/index.js | 2 +- .../math/base/special/round10f/include.gypi | 53 ++++++ .../stdlib/math/base/special/round10f.h | 2 +- .../math/base/special/round10f/lib/index.js | 2 +- .../math/base/special/round10f/lib/main.js | 2 +- .../math/base/special/round10f/lib/native.js | 2 +- .../math/base/special/round10f/manifest.json | 80 +++++++++ .../math/base/special/round10f/src/addon.c | 2 +- .../math/base/special/round10f/src/main.c | 25 +-- .../math/base/special/round10f/test/test.js | 2 +- .../base/special/round10f/test/test.native.js | 2 +- 21 files changed, 619 insertions(+), 33 deletions(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/manifest.json diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index 04bacaa0afae..d57cf12c6f4d 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2026 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -82,7 +82,7 @@ for ( i = 0; i < x.length; i++ ) { var n = -1; function fcn( v ) { - return round10f( v); + return round10f( v, n ); } logEachMap('x: %0.4f. Rounded: %0.4f.', x, fcn); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js index 3e2b55ea1b8a..b57b4e6dd32e 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js index 549f37eb6359..e3d4b1a3b2cd 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c index ec6895fb4bd3..294d33c7899c 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/binding.gyp b/lib/node_modules/@stdlib/math/base/special/round10f/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts index 91202c272d33..349e3d0cabf0 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts index 9e9f06dd0722..ef883c00da79 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c index 495e21078811..2e843f40dcdf 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js index cf595322fbd5..cb81d08138ec 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/include.gypi b/lib/node_modules/@stdlib/math/base/special/round10f/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' -/** -* Rounds a single-precision floating-point number to the nearest multiple -* of `10^n` using round-to-nearest-even. -* -* @param x input value -* @param n integer power of 10 indicating the decimal place -* @return rounded value -*/ float stdlib_base_round10f( const float x, const int32_t n ) { float s; float y; - /* Propagate NaN and ±infinity: */ + /* Handle NaN and ±infinity: */ if ( stdlib_base_is_nanf( x ) || stdlib_base_is_infinitef( x ) ) { return x; } - /* Preserve sign of ±0.0: */ + /* Preserve ±0.0: */ if ( x == 0.0f ) { return x; } - /* Scale by 10^(-n): */ + /* Scale */ s = stdlib_base_powf( 10.0f, (float)(-n) ); - y = stdlib_base_to_float32( x * s ); + y = (float)( x * s ); - /* Round (ties-to-even): */ + /* Round ties-to-even */ y = stdlib_base_roundf( y ); - /* Scale back: */ - y = stdlib_base_to_float32( y / s ); + /* Scale back */ + y = (float)( y / s ); return y; } diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js index eed536cef5dd..c6f7a74c193a 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js index 5c33ba318bf0..311c3fa56c96 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 7373d1a27155e9616d85222cadb2e76080ed4ad2 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:35:03 +0000 Subject: [PATCH 04/22] feat: add math/base/special/round10f --- 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: na - 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: 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 --- --- .../math/base/special/round10f/README.md | 37 ++++++++----------- .../base/special/round10f/examples/c/Makefile | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index d57cf12c6f4d..d94e76122886 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -20,7 +20,7 @@ limitations under the License. # round10f -> Round a numeric value to the nearest multiple of \\(10^n\\) using single-precision floating-point arithmetic. +> Round a numeric value to the nearest power of ten using single-precision floating-point arithmetic.
@@ -30,27 +30,27 @@ limitations under the License. var round10f = require( '@stdlib/math/base/special/round10f' ); ``` -#### round10f( x, n ) +#### round10f( x ) Rounds a numeric value to the nearest multiple of 10^n usingsingle-precision floating-point arithmetic. ```javascript var y; -y = round10f( 3.1415926, -2 ); -// returns 1 +y = round10f( 3.1415926 ); +// returns 1.0 -y = round10f( 3.1415926, 0 ); -// returns 1 +y = round10f( 123.456 ); +// returns 100.0 -y = round10f( 123.456, 1 ); -// returns 100 +y = round10f( 999.0 ); +// returns 1000.0 -y = round10f( -2.5, 0 ); -// returns -1 +y = round10f( -2.5 ); +// returns -1.0 -y = round10f( -0.0, 0 ); -// returns -0 +y = round10f( -0.0 ); +// returns -0.0 ```
@@ -63,8 +63,8 @@ y = round10f( -0.0, 0 ); ```javascript var uniform = require( '@stdlib/random/array/uniform' ); -var logEachMap = require( '@stdlib/console/log-each-map' ); var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var logEach = require( '@stdlib/console/log-each' ); var round10f = require( '@stdlib/math/base/special/round10f' ); var opts = { @@ -73,19 +73,12 @@ var opts = { var x = uniform( 100, -50.0, 50.0, opts ); -// Ensure float32 precision: var i; for ( i = 0; i < x.length; i++ ) { x[ i ] = toFloat32( x[ i ] ); } -var n = -1; - -function fcn( v ) { - return round10f( v, n ); -} - -logEachMap('x: %0.4f. Rounded: %0.4f.', x, fcn); +logEach( 'x: %d => %d', x, round10f ); ``` @@ -115,7 +108,7 @@ This package provides a C API for rounding single-precision floating-point numbe #include "stdlib/math/base/special/round10f.h" ``` -#### stdlib_base_round10f( x, n ) +#### stdlib_base_round10f( x ) Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\). diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile index 6aed70daf167..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2026 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 666c9a0e3ae4e9745aeaad108cf751f18ef70adc Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:37:31 +0000 Subject: [PATCH 05/22] feat: add math/base/special/round10f --- 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: na - 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: 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 --- --- lib/node_modules/@stdlib/math/base/special/round10f/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index d94e76122886..b6685b742a59 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -43,9 +43,6 @@ y = round10f( 3.1415926 ); y = round10f( 123.456 ); // returns 100.0 -y = round10f( 999.0 ); -// returns 1000.0 - y = round10f( -2.5 ); // returns -1.0 From a391f9795afe1123920338789b5418e64efb0268 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:43:38 +0000 Subject: [PATCH 06/22] feat: add math/base/special/round10f --- 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: na - 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: 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 --- --- .../math/base/special/round10f/README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index b6685b742a59..3cfe46612faa 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -110,24 +110,23 @@ This package provides a C API for rounding single-precision floating-point numbe Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\). ```c -float out = stdlib_base_round10f( 3.14f, 0 ); -// returns 3.0f +float out = stdlib_base_round10f( 3.14f ); +// returns 1.0f -out = stdlib_base_round10f( 3.14f, -1 ); -// returns 3.1f +out = stdlib_base_round10f( 123.456f ); +// returns 100.0f ``` **Arguments** -- **x**: `[in] float` input value. -- **n**: `[in] int32_t` power of ten exponent. +- **x**: `[in] float` input value. **Returns** - `float`: rounded value. ```c -float stdlib_base_round10f( const float x, const int32_t n ); +float stdlib_base_round10f( const float x ); ``` @@ -147,13 +146,12 @@ int main( void ) { -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, 0.56f, 1.67f, 2.78f, 3.89f, 5.0f }; - const int n = -1; float v; int i; for ( i = 0; i < 10; i++ ) { - v = stdlib_base_round10f( x[ i ], n ); - printf( "round10f(%f,%d) = %f\n", x[ i ], n, v ); + v = stdlib_base_round10f( x[ i ] ); + printf( "round10f(%f) = %f\n", x[ i ], v ); } } ``` From 8e3bc57956c45ec87abecabac6b55dbad5e132a8 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:54:44 +0000 Subject: [PATCH 07/22] feat: add math/base/special/round10f --- 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: missing_dependencies - 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/round10f.h | 3 +- .../math/base/special/round10f/lib/index.js | 14 +++--- .../math/base/special/round10f/lib/native.js | 17 ++++---- .../math/base/special/round10f/src/addon.c | 4 +- .../math/base/special/round10f/src/main.c | 43 +++++++++++-------- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h index 4324e5496911..37a6b9f24c28 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h +++ b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h @@ -32,10 +32,9 @@ extern "C" { * Rounds a single-precision floating-point number to the nearest multiple of `10^n`. * * @param x input value -* @param n integer power of 10 specifying the decimal place * @return rounded value */ -float stdlib_base_round10f( const float x, const int32_t n ); +float stdlib_base_round10f( const float x ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js index 6e81b6555409..38b43ec4729d 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2026 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,17 +26,17 @@ * @example * var round10f = require( '@stdlib/math/base/special/round10f' ); * -* var v = round10f( 3.1415926, 0 ); +* var v = round10f( 3.1415926 ); * // returns 1 * -* v = round10f( 3.1415926, -1 ); -* // returns 1 -* -* v = round10f( 123.45, 1 ); +* v = round10f( 123.45 ); * // returns 100 * -* v = round10f( -2.5, 0 ); +* v = round10f( -2.5 ); * // returns -1 +* +* v = round10f( -0.0 ); +* // returns -0 */ // MODULES // diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js index 5b570cc76a38..7ea2f073f429 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js @@ -30,21 +30,20 @@ var addon = require( './../src/addon.node' ); * * @private * @param {number} x - input value -* @param {integer} n - integer power of 10 specifying the decimal place * @returns {number} rounded value * * @example -* var v = round10f( 3.1415926, 0 ); -* // returns 3.0 +* var v = round10f( 3.1415926 ); +* // returns 1.0 * -* v = round10f( 3.1415926, -1 ); -* // returns 3.1 +* v = round10f( 123.45 ); +* // returns 100.0 * -* v = round10f( 123.45, 1 ); -* // returns 120.0 +* v = round10f( -2.5 ); +* // returns -1.0 */ -function round10f( x, n ) { - return addon( x, n ); +function round10f( x ) { + return addon( x ); } diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c index 9cdfa8d15f07..80d60f0dddd0 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/addon.c @@ -17,6 +17,6 @@ */ #include "stdlib/math/base/special/round10f.h" -#include "stdlib/math/base/napi/binary.h" +#include "stdlib/math/base/napi/unary.h" -STDLIB_MATH_BASE_NAPI_MODULE_FI_F( stdlib_base_round10f ) +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_round10f ) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c index 138f79e57f0a..27495b56861b 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c @@ -19,33 +19,42 @@ #include "stdlib/math/base/special/round10f.h" #include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/assert/is_infinitef.h" -#include "stdlib/math/base/special/roundf.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/log10f.h" +#include "stdlib/math/base/special/floorf.h" #include "stdlib/math/base/special/powf.h" -#include -float stdlib_base_round10f( const float x, const int32_t n ) { - float s; - float y; +float stdlib_base_round10f( const float x ) { + float ax; + float e0; + float e1; + float y0; + float y1; - /* Handle NaN and ±infinity: */ + /* NaN / ±inf → return input */ if ( stdlib_base_is_nanf( x ) || stdlib_base_is_infinitef( x ) ) { - return x; + return x; } - /* Preserve ±0.0: */ + /* preserve ±0.0f */ if ( x == 0.0f ) { - return x; + return x; } - /* Scale */ - s = stdlib_base_powf( 10.0f, (float)(-n) ); - y = (float)( x * s ); + /* absolute value */ + ax = stdlib_base_absf( x ); - /* Round ties-to-even */ - y = stdlib_base_roundf( y ); + /* exponent below and above */ + e0 = stdlib_base_floorf( stdlib_base_log10f( ax ) ); + e1 = e0 + 1.0f; - /* Scale back */ - y = (float)( y / s ); + /* powers */ + y0 = stdlib_base_powf( 10.0f, e0 ); + y1 = stdlib_base_powf( 10.0f, e1 ); - return y; + /* choose nearest */ + if ( (ax - y0) <= (y1 - ax) ) { + return ( x < 0.0f ) ? -y0 : y0; + } + return ( x < 0.0f ) ? -y1 : y1; } From b15dfe78b2562b9867eda64de5d71d5beec3d8fb Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 20:59:03 +0000 Subject: [PATCH 08/22] feat: add math/base/special/round10f --- 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: na - 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: 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/round10f/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index 3cfe46612faa..cf019c2ea744 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -20,7 +20,7 @@ limitations under the License. # round10f -> Round a numeric value to the nearest power of ten using single-precision floating-point arithmetic. +Rounds a numeric value to the nearest power of ten using single-precision floating-point arithmetic.
@@ -32,7 +32,7 @@ var round10f = require( '@stdlib/math/base/special/round10f' ); #### round10f( x ) -Rounds a numeric value to the nearest multiple of 10^n usingsingle-precision floating-point arithmetic. +Rounds a numeric value to the nearest power of ten using single-precision floating-point arithmetic. ```javascript var y; @@ -91,7 +91,7 @@ logEach( 'x: %d => %d', x, round10f );
-This package provides a C API for rounding single-precision floating-point numbers to the nearest multiple of \\(10^n\\). +This package provides a C API for rounding single-precision floating-point numbers to the nearest power of ten.
@@ -107,7 +107,7 @@ This package provides a C API for rounding single-precision floating-point numbe #### stdlib_base_round10f( x ) -Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\). +Rounds a single-precision floating-point number to the nearest power of ten. ```c float out = stdlib_base_round10f( 3.14f ); From fa5b9f466d6a771395139e43ee175bcc75b7f995 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 21:05:10 +0000 Subject: [PATCH 09/22] feat: unary round10f --- 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: na - task: lint_c_examples status: missing_dependencies - 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 --- --- .../base/special/round10f/examples/c/example.c | 18 ++++++------------ .../stdlib/math/base/special/round10f.h | 2 +- .../math/base/special/round10f/lib/index.js | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c index 2e843f40dcdf..ec6fc1eab841 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c @@ -21,22 +21,16 @@ int main( void ) { const float x[] = { - -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, - 0.56f, 1.67f, 2.78f, 3.89f, 5.0f + -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, + 0.56f, 1.67f, 2.78f, 3.89f, 5.0f }; - /* Round to 0.1, 1, and 10: */ - const int exps[] = { -1, 0, 1 }; - float v; int i; - int j; - - for ( j = 0; j < 3; j++ ) { - for ( i = 0; i < 10; i++ ) { - v = stdlib_base_round10f( x[ i ], exps[ j ] ); - printf( "round10f(%f,%d) = %f\n", x[ i ], exps[ j ], v ); - } + for ( i = 0; i < 10; i++ ) { + v = stdlib_base_round10f( x[ i ] ); + printf( "round10f(%f) = %f\n", x[ i ], v ); } return 0; } + diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h index 37a6b9f24c28..2476be54f28c 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h +++ b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h @@ -29,7 +29,7 @@ extern "C" { #include /* -* Rounds a single-precision floating-point number to the nearest multiple of `10^n`. +* Rounds a single-precision floating-point number to the nearest power of ten. * * @param x input value * @return rounded value diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js index 38b43ec4729d..0889c2b6181d 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Round a single-precision floating-point number to the nearest multiple of `10^n`. +* Round a single-precision floating-point number to the nearest power of ten. * * @module @stdlib/math/base/special/round10f * From 97811fcdf2e93bf0ffe22a5037d37d77b2aac96c Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 21:09:26 +0000 Subject: [PATCH 10/22] feat: unary round10f --- 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: na - 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: missing_dependencies - 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 --- --- .../math/base/special/round10f/src/main.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c index 27495b56861b..bd65249e22bc 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c @@ -20,9 +20,9 @@ #include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/assert/is_infinitef.h" #include "stdlib/math/base/special/absf.h" -#include "stdlib/math/base/special/log10f.h" #include "stdlib/math/base/special/floorf.h" #include "stdlib/math/base/special/powf.h" +#include "stdlib/math/base/special/log10.h" float stdlib_base_round10f( const float x ) { float ax; @@ -31,30 +31,32 @@ float stdlib_base_round10f( const float x ) { float y0; float y1; - /* NaN / ±inf → return input */ + /* NaN and ±inf return input */ if ( stdlib_base_is_nanf( x ) || stdlib_base_is_infinitef( x ) ) { - return x; + return x; } - /* preserve ±0.0f */ + /* Preserve ±0.0f */ if ( x == 0.0f ) { - return x; + return x; } - /* absolute value */ + /* abs(x) */ ax = stdlib_base_absf( x ); - /* exponent below and above */ - e0 = stdlib_base_floorf( stdlib_base_log10f( ax ) ); + /* lower exponent = floor(log10(ax)) */ + e0 = stdlib_base_floorf( (float)stdlib_base_log10( ax ) ); + + /* next exponent */ e1 = e0 + 1.0f; /* powers */ y0 = stdlib_base_powf( 10.0f, e0 ); y1 = stdlib_base_powf( 10.0f, e1 ); - /* choose nearest */ + /* return whichever is closer */ if ( (ax - y0) <= (y1 - ax) ) { - return ( x < 0.0f ) ? -y0 : y0; + return ( x < 0.0f ) ? -y0 : y0; } return ( x < 0.0f ) ? -y1 : y1; } From fa5042b37f8f259482067cae5bb4594ab0da59fd Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 21:12:37 +0000 Subject: [PATCH 11/22] feat: unary round10f --- 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: na - 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: 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 --- --- .../math/base/special/round10f/src/Makefile | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/round10f/src/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/src/Makefile new file mode 100644 index 000000000000..3f38164b44e1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/Makefile @@ -0,0 +1,71 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean + From c735e6d681f1985bf7159de463bdb0e408ec96fe Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Mon, 5 Jan 2026 21:16:13 +0000 Subject: [PATCH 12/22] feat: unary round10f --- 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: na - 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: 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/round10f/examples/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile index c8f8e9a1517b..6aed70daf167 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2026 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 5a288bb393d4e71cf41ed8623a0fab9ba86322d9 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 18:48:12 +0000 Subject: [PATCH 13/22] feat: unary round10f --- 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: na - 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: 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/round10f/manifest.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json index e9f5153dbae8..8ee3fdd00f61 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json @@ -39,7 +39,9 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/roundf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/floorf" ] }, { @@ -56,7 +58,9 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/roundf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/floorf" ] }, { @@ -73,7 +77,9 @@ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/roundf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10", + "@stdlib/math/base/special/floorf" ] } ] From 26ff1cb3a82f8cb5047aeb770a17c37d460abcac Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 18:56:33 +0000 Subject: [PATCH 14/22] feat: unary round10f --- 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: na - 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: 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/round10f/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index cf019c2ea744..751ece673efd 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -20,7 +20,7 @@ limitations under the License. # round10f -Rounds a numeric value to the nearest power of ten using single-precision floating-point arithmetic. +> Round a numeric value to the nearest power of ten using single-precision floating-point arithmetic.
@@ -32,7 +32,7 @@ var round10f = require( '@stdlib/math/base/special/round10f' ); #### round10f( x ) -Rounds a numeric value to the nearest power of ten using single-precision floating-point arithmetic. +Rounds a `numeric` value to the nearest power of ten using single-precision floating-point arithmetic. ```javascript var y; @@ -91,7 +91,7 @@ logEach( 'x: %d => %d', x, round10f );
-This package provides a C API for rounding single-precision floating-point numbers to the nearest power of ten. +This package provides a C API for rounding single-precision floating-point numbers to the nearest power of \\(10\\).
From 3097893091a2124d641039f5cf5fdebd8533118c Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 19:03:14 +0000 Subject: [PATCH 15/22] feat: unary round10f --- 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: na - 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 --- --- .../base/special/round10f/test/test.native.js | 70 ++++++------------- 1 file changed, 20 insertions(+), 50 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js index 311c3fa56c96..e514543e2aab 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js @@ -47,70 +47,40 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { - var v = round10f( toFloat32( +0.0 ), 0 ); - t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); +tape( 'returns +0 if +0', opts, function test( t ) { + var v = round10f( toFloat32( +0.0 ) ); + t.strictEqual( isPositiveZero( v ), true ); t.end(); }); -tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { - var v = round10f( toFloat32( -0.0 ), 0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); +tape( 'returns -0 if -0', opts, function test( t ) { + var v = round10f( toFloat32( -0.0 ) ); + t.strictEqual( isNegativeZero( v ), true ); t.end(); }); -tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { - var v = round10f( NaN, 0 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); +tape( 'returns NaN if NaN', opts, function test( t ) { + var v = round10f( NaN ); + t.strictEqual( isnan( v ), true ); t.end(); }); -tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { - var v = round10f( PINF, 0 ); - t.strictEqual( v, PINF, 'returns +infinity' ); +tape( 'returns +inf if +inf', opts, function test( t ) { + var v = round10f( PINF ); + t.strictEqual( v, PINF ); t.end(); }); -tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { - var v = round10f( NINF, 0 ); - t.strictEqual( v, NINF, 'returns -infinity' ); +tape( 'returns -inf if -inf', opts, function test( t ) { + var v = round10f( NINF ); + t.strictEqual( v, NINF ); t.end(); }); -tape( 'the function rounds to the nearest integer when n = 0', opts, function test( t ) { - t.strictEqual( round10f( 3.14, 0 ), 3.0, '3.14 -> 3' ); - t.strictEqual( round10f( 3.5, 0 ), 4.0, 'ties-to-even' ); - t.strictEqual( round10f( 2.5, 0 ), 2.0, 'ties-to-even' ); - t.strictEqual( round10f( -2.5, 0 ), -2.0, 'ties-to-even' ); - t.end(); -}); - -tape( 'the function rounds to the nearest tenth when n = -1', opts, function test( t ) { - t.strictEqual( round10f( 3.14, -1 ), toFloat32( 3.1 ), '3.14 -> 3.1' ); - t.strictEqual( round10f( 3.15, -1 ), toFloat32( 3.2 ), '3.15 -> 3.2' ); - t.end(); -}); - -tape( 'the function rounds to the nearest hundredth when n = -2', opts, function test( t ) { - t.strictEqual( round10f( 1.234, -2 ), toFloat32( 1.23 ), '1.234 -> 1.23' ); - t.strictEqual( round10f( 1.235, -2 ), toFloat32( 1.24 ), 'ties handled' ); - t.end(); -}); - -tape( 'the function rounds to the nearest 10 when n = 1', opts, function test( t ) { - t.strictEqual( round10f( 17.2, 1 ), 20.0, '17.2 -> 20' ); - t.strictEqual( round10f( 14.9, 1 ), 10.0, '14.9 -> 10' ); - t.end(); -}); - -tape( 'the function rounds to the nearest 100 when n = 2', opts, function test( t ) { - t.strictEqual( round10f( 249.0, 2 ), 200.0, '249 -> 200' ); - t.strictEqual( round10f( 250.0, 2 ), 300.0, 'ties-to-even' ); - t.end(); -}); - -tape( 'the function preserves signed zeros after rounding', opts, function test( t ) { - t.strictEqual( isPositiveZero( round10f( +0.04, -1 ) ), true, '+0 stays +0' ); - t.strictEqual( isNegativeZero( round10f( -0.04, -1 ) ), true, '-0 stays -0' ); +tape( 'rounds to nearest power of 10', opts, function test( t ) { + t.strictEqual( round10f( toFloat32( -4.2 ) ), toFloat32( -1.0 ) ); + t.strictEqual( round10f( toFloat32( 9.4 ) ), toFloat32( 10.0 ) ); + t.strictEqual( round10f( toFloat32( 60.1 ) ), toFloat32( 100.0 ) ); + t.strictEqual( round10f( toFloat32( 0.3 ) ), toFloat32( 0.1 ) ); t.end(); }); From ac44e62c84caca454aee52af2f41ba46e438eff1 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 19:08:56 +0000 Subject: [PATCH 16/22] feat: fix round10f --- 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: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - 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: missing_dependencies - 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 --- --- .../math/base/special/round10f/benchmark/benchmark.js | 5 +---- .../special/round10f/benchmark/benchmark.native.js | 11 ++++------- .../special/round10f/benchmark/c/native/benchmark.c | 11 ++++------- .../math/base/special/round10f/examples/index.js | 10 ++-------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js index b57b4e6dd32e..44fb272997c9 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.js @@ -31,7 +31,6 @@ var pkg = require( './../package.json' ).name; // MAIN // bench( pkg, function benchmark( b ) { - var exps; var x; var y; var i; @@ -42,11 +41,9 @@ bench( pkg, function benchmark( b ) { x[ i ] = toFloat32( x[ i ] ); } - exps = [ -3, -1, 0, 1, 3 ]; - b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = round10f( x[ i % x.length ], exps[ i % exps.length ] ); + y = round10f( x[ i % x.length ] ); if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js index e3d4b1a3b2cd..d7c5a564d230 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/benchmark.native.js @@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -41,7 +41,6 @@ var opts = { // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var exps; var x; var y; var i; @@ -52,18 +51,16 @@ bench( format( '%s::native', pkg ), opts, function benchmark( b ) { x[ i ] = toFloat32( x[ i ] ); } - exps = [ -3, -1, 0, 1, 3 ]; - b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = round10f( x[ i % x.length ], exps[ i % exps.length ] ); - if ( isnan( y ) ) { + y = round10f( x[ i % x.length ] ); + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c index 294d33c7899c..f343b18a9b2e 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/benchmark/c/native/benchmark.c @@ -29,7 +29,7 @@ static double tic( void ) { struct timeval now; gettimeofday( &now, NULL ); - return (double)now.tv_sec + (double)now.tv_usec/1.0e6; + return (double)now.tv_sec + (double)now.tv_usec / 1.0e6; } static float rand_float( void ) { @@ -38,21 +38,18 @@ static float rand_float( void ) { static double benchmark( void ) { float x[100]; - const int exps[5] = { -3, -1, 0, 1, 3 }; - volatile float y; /* prevent optimization */ + volatile float y; /* prevent compiler optimization */ double elapsed; double t; int i; - int n; for ( i = 0; i < 100; i++ ) { - x[i] = ( 1.0e4f * rand_float() ) - 5.0e3f; + x[ i ] = ( 1.0e4f * rand_float() ) - 5.0e3f; } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - n = exps[ i % 5 ]; - y = stdlib_base_round10f( x[ i % 100 ], n ); + y = stdlib_base_round10f( x[ i % 100 ] ); } elapsed = tic() - t; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js index cb81d08138ec..0479cdabb88c 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js @@ -19,7 +19,7 @@ 'use strict'; var uniform = require( '@stdlib/random/array/uniform' ); -var logEachMap = require( '@stdlib/console/log-each-map' ); +var logEach = require( '@stdlib/console/log-each' ); var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); var round10f = require( './../lib' ); @@ -35,10 +35,4 @@ for ( i = 0; i < x.length; i++ ) { x[ i ] = toFloat32( x[ i ] ); } -var n = -1; - -function fcn( v ) { - return round10f( v, n ); -} - -logEachMap( 'x: %0.4f. Rounded: %0.4f.', x, fcn ); +logEach( 'x: %0.4f => %0.4f', x, round10f ); From 2839fc0ce86d729399b8bd2fe9533d82a7c8695f Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 19:10:49 +0000 Subject: [PATCH 17/22] feat: fix round10f --- 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: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: 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 --- --- .../math/base/special/round10f/examples/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js index 0479cdabb88c..b7b42519e658 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/index.js @@ -19,8 +19,8 @@ 'use strict'; var uniform = require( '@stdlib/random/array/uniform' ); -var logEach = require( '@stdlib/console/log-each' ); var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round10f = require( './../lib' ); var opts = { @@ -29,10 +29,14 @@ var opts = { var x = uniform( 100, -50.0, 50.0, opts ); -// Ensure float32 precision: +// ensure float32 precision: var i; for ( i = 0; i < x.length; i++ ) { x[ i ] = toFloat32( x[ i ] ); } -logEach( 'x: %0.4f => %0.4f', x, round10f ); +function fcn( v ) { + return round10f( v ); +} + +logEachMap( 'x: %0.4f => %0.4f', x, fcn ); From 21e0582ca5aff8256676c8d14a481918ae708d19 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 19:15:09 +0000 Subject: [PATCH 18/22] feat: fix round10f --- 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: na - 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: 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/round10f/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/README.md b/lib/node_modules/@stdlib/math/base/special/round10f/README.md index 751ece673efd..116efc156969 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/README.md +++ b/lib/node_modules/@stdlib/math/base/special/round10f/README.md @@ -61,7 +61,7 @@ y = round10f( -0.0 ); ```javascript var uniform = require( '@stdlib/random/array/uniform' ); var toFloat32 = require( '@stdlib/number/float64/base/to-float32' ); -var logEach = require( '@stdlib/console/log-each' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var round10f = require( '@stdlib/math/base/special/round10f' ); var opts = { @@ -70,12 +70,17 @@ var opts = { var x = uniform( 100, -50.0, 50.0, opts ); +// Ensure float32 precision: var i; for ( i = 0; i < x.length; i++ ) { x[ i ] = toFloat32( x[ i ] ); } -logEach( 'x: %d => %d', x, round10f ); +function fcn( v ) { + return round10f( v ); +} + +logEachMap( 'x: %0.4f => %0.4f', x, fcn ); ```
From f3637a1a283979dbf5575d98b872c8221559b4c9 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Tue, 6 Jan 2026 19:22:25 +0000 Subject: [PATCH 19/22] fix: update year headers and correct examples/c/Makefile + lib/index.js --- 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: 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/round10f/examples/c/Makefile | 2 +- .../@stdlib/math/base/special/round10f/lib/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile index 6aed70daf167..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2026 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js index 0889c2b6181d..2e85eb95a9e3 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 4330a92ec5061b5cd748a6e38a05968610f00bc0 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Wed, 7 Jan 2026 18:15:06 +0000 Subject: [PATCH 20/22] fix: main.js + index.d.ts + test.ts + repl.txt --- 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: passed - 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: missing_dependencies - 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: passed - task: lint_license_headers status: passed --- --- .../math/base/special/round10f/docs/repl.txt | 23 ++++++------ .../special/round10f/docs/types/index.d.ts | 17 ++++----- .../base/special/round10f/docs/types/test.ts | 37 ++++++------------- .../math/base/special/round10f/lib/main.js | 16 ++++++++ .../math/base/special/round10f/manifest.json | 15 +++++--- .../math/base/special/round10f/src/main.c | 8 ++-- .../base/special/round10f/test/test.native.js | 36 ++++++++++-------- 7 files changed, 81 insertions(+), 71 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt index ef90008ba090..65246aafa87c 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/repl.txt @@ -1,13 +1,11 @@ -{{alias}}( x, n ) - Rounds a numeric value to the nearest multiple of 10^n using +{{alias}}( x ) + Rounds a numeric value to the nearest power of ten using single-precision floating-point arithmetic. Parameters ---------- x: number Input value. - n: number - Integer power of 10 specifying the decimal place to which to round. Returns ------- @@ -16,16 +14,17 @@ Examples -------- - > var y = {{alias}}( 3.1415926, -2 ) - 1 - > y = {{alias}}( 3.1415926, 0 ) - 1 - > y = {{alias}}( 123.456, 2 ) + > var y = {{alias}}( 3.1415926 ) + 1.0 + > y = {{alias}}( 123.456 ) 100.0 - > y = {{alias}}( -2.5, 0 ) - -1 - > y = {{alias}}( -0.0, 0 ) + > y = {{alias}}( 9.5 ) + 10.0 + > y = {{alias}}( -2.5 ) + -1.0 + > y = {{alias}}( -0.0 ) -0.0 See Also -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts index 349e3d0cabf0..77fed735503a 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts @@ -20,26 +20,25 @@ * Rounds a numeric value to the nearest power of 10 on a linear scale (single-precision). * * @param x - input value -* @param n - decimal exponent * @returns rounded value * * @example -* var v = round10f( 3.1415926, 0 ); -* // returns 1 +* var v = round10f( 3.1415926 ); +* // returns 1.0 * * @example -* var v = round10f( 3.1415926, -1 ); -* // returns 1 +* var v = round10f( 13.0 ); +* // returns 10.0 * * @example -* var v = round10f( 123.0, 1 ); -* // returns 100 +* var v = round10f( -0.314 ); +* // returns -0.10000000149011612 * * @example -* var v = round10f( NaN, 2 ); +* var v = round10f( NaN ); * // returns NaN */ -declare function round10f( x: number, n: number ): number; +declare function round10f( x: number ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts index ef883c00da79..3659b22e7be4 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/test.ts @@ -22,37 +22,24 @@ import round10f = require( './index' ); // The function returns a number... { - round10f( 8.78, 2 ); // $ExpectType number - round10f( 8.78, 0 ); // $ExpectType number - round10f( 8.78, -2 ); // $ExpectType number + round10f( 8.78 ); // $ExpectType number + round10f( 0.5 ); // $ExpectType number + round10f( -3.2 ); // $ExpectType number } -// The compiler throws an error if the function is provided a first argument other than a number... +// The compiler throws an error if the function is provided an argument other than a number... { - round10f( true, 1 ); // $ExpectError - round10f( false, 1 ); // $ExpectError - round10f( null, 1 ); // $ExpectError - round10f( undefined, 1 ); // $ExpectError - round10f( '5', 1 ); // $ExpectError - round10f( [], 1 ); // $ExpectError - round10f( {}, 1 ); // $ExpectError - round10f( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument other than a number... -{ - round10f( 3.14, true ); // $ExpectError - round10f( 3.14, false ); // $ExpectError - round10f( 3.14, null ); // $ExpectError - round10f( 3.14, undefined ); // $ExpectError - round10f( 3.14, '5' ); // $ExpectError - round10f( 3.14, [] ); // $ExpectError - round10f( 3.14, {} ); // $ExpectError - round10f( 3.14, ( x: number ): number => x ); // $ExpectError + round10f( true ); // $ExpectError + round10f( false ); // $ExpectError + round10f( null ); // $ExpectError + round10f( undefined ); // $ExpectError + round10f( '5' ); // $ExpectError + round10f( [] ); // $ExpectError + round10f( {} ); // $ExpectError + round10f( ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided insufficient arguments... { round10f(); // $ExpectError - round10f( 3.14 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js index 517ad440fc15..6a1a62692a68 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/main.js @@ -36,6 +36,22 @@ var log10 = require( '@stdlib/math/base/special/log10' ); * * @param {number} x - input value * @returns {number} rounded value (float32) +* +* @example +* var v = round10f( 3.1415926 ); +* // returns 1.0 +* +* @example +* var v = round10f( 123.45 ); +* // returns 100.0 +* +* @example +* var v = round10f( -2.5 ); +* // returns -1.0 +* +* @example +* var v = round10f( -0.0 ); +* // returns -0.0 */ function round10f( x ) { var ax; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json index 8ee3fdd00f61..79275022f582 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json @@ -38,10 +38,11 @@ "dependencies": [ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", - "@stdlib/math/base/special/roundf", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/powf", "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/floorf" + "@stdlib/math/base/special/roundf" ] }, { @@ -57,10 +58,11 @@ "dependencies": [ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", - "@stdlib/math/base/special/roundf", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/powf", "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/floorf" + "@stdlib/math/base/special/roundf" ] }, { @@ -76,10 +78,11 @@ "dependencies": [ "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", - "@stdlib/math/base/special/roundf", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/powf", "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/floorf" + "@stdlib/math/base/special/roundf" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c index bd65249e22bc..b6f73655c8cc 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c @@ -17,12 +17,12 @@ */ #include "stdlib/math/base/special/round10f.h" -#include "stdlib/math/base/assert/is_nanf.h" -#include "stdlib/math/base/assert/is_infinitef.h" +#include "stdlib/math/base/assert/is_nanf.h". +#include "stdlib/math/base/assert/is_infinitef.h". #include "stdlib/math/base/special/absf.h" #include "stdlib/math/base/special/floorf.h" -#include "stdlib/math/base/special/powf.h" -#include "stdlib/math/base/special/log10.h" +#include "stdlib/math/base/special/powf.h". +#include "stdlib/math/base/special/log10.h". float stdlib_base_round10f( const float x ) { float ax; diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js index e514543e2aab..9287d807619b 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/test/test.native.js @@ -47,40 +47,46 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'returns +0 if +0', opts, function test( t ) { +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { var v = round10f( toFloat32( +0.0 ) ); - t.strictEqual( isPositiveZero( v ), true ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); t.end(); }); -tape( 'returns -0 if -0', opts, function test( t ) { +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = round10f( toFloat32( -0.0 ) ); - t.strictEqual( isNegativeZero( v ), true ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); t.end(); }); -tape( 'returns NaN if NaN', opts, function test( t ) { +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = round10f( NaN ); - t.strictEqual( isnan( v ), true ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); }); -tape( 'returns +inf if +inf', opts, function test( t ) { +tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { var v = round10f( PINF ); - t.strictEqual( v, PINF ); + t.strictEqual( v, PINF, 'returns +infinity' ); t.end(); }); -tape( 'returns -inf if -inf', opts, function test( t ) { +tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { var v = round10f( NINF ); - t.strictEqual( v, NINF ); + t.strictEqual( v, NINF, 'returns -infinity' ); t.end(); }); -tape( 'rounds to nearest power of 10', opts, function test( t ) { - t.strictEqual( round10f( toFloat32( -4.2 ) ), toFloat32( -1.0 ) ); - t.strictEqual( round10f( toFloat32( 9.4 ) ), toFloat32( 10.0 ) ); - t.strictEqual( round10f( toFloat32( 60.1 ) ), toFloat32( 100.0 ) ); - t.strictEqual( round10f( toFloat32( 0.3 ) ), toFloat32( 0.1 ) ); +tape( 'the function rounds to the nearest power of 10 on a linear scale', opts, function test( t ) { + t.strictEqual( round10f( toFloat32( -4.2 ) ), toFloat32( -1.0 ), '-4.2 -> -1' ); + t.strictEqual( round10f( toFloat32( -4.8 ) ), toFloat32( -1.0 ), '-4.8 -> -1' ); + t.strictEqual( round10f( toFloat32( 4.2 ) ), toFloat32( 1.0 ), '4.2 -> 1' ); + t.strictEqual( round10f( toFloat32( 9.4 ) ), toFloat32( 10.0 ), '9.4 -> 10' ); + t.strictEqual( round10f( toFloat32( 9.5 ) ), toFloat32( 10.0 ), '9.5 -> 10' ); + t.strictEqual( round10f( toFloat32( 12.0 ) ), toFloat32( 10.0 ), '12 -> 10' ); + t.strictEqual( round10f( toFloat32( -12.0 ) ), toFloat32( -10.0 ), '-12 -> -10' ); + t.strictEqual( round10f( toFloat32( 60.1 ) ), toFloat32( 100.0 ), '60.1 -> 100' ); + t.strictEqual( round10f( toFloat32( 0.3 ) ), toFloat32( 0.1 ), '0.3 -> 0.1' ); + t.strictEqual( round10f( toFloat32( 0.61 ) ), toFloat32( 1.0 ), '0.61 -> 1' ); t.end(); }); From 0077706e631b4a37b9abc8d42dac9e6a4777c081 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 10 Jan 2026 17:01:55 +0000 Subject: [PATCH 21/22] fix: address review feedback for round10f C implementation and docs --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - 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: passed - task: lint_license_headers status: passed --- --- .../math/base/special/round10f/docs/types/index.d.ts | 2 ++ .../math/base/special/round10f/examples/c/example.c | 11 ++++++----- .../include/stdlib/math/base/special/round10f.h | 5 ++--- .../@stdlib/math/base/special/round10f/lib/native.js | 2 +- .../@stdlib/math/base/special/round10f/manifest.json | 12 +++--------- .../@stdlib/math/base/special/round10f/src/main.c | 8 ++++---- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts index 77fed735503a..be52154bad0b 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/round10f/docs/types/index.d.ts @@ -16,6 +16,8 @@ * limitations under the License. */ +// TypeScript Version: 4.1 + /** * Rounds a numeric value to the nearest power of 10 on a linear scale (single-precision). * diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c index ec6fc1eab841..8be612b4286a 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/examples/c/example.c @@ -21,16 +21,17 @@ int main( void ) { const float x[] = { - -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, - 0.56f, 1.67f, 2.78f, 3.89f, 5.0f + -5.0f, -3.89f, -2.78f, -1.67f, -0.56f, + 0.56f, 1.67f, 2.78f, 3.89f, 5.0f }; float v; int i; + for ( i = 0; i < 10; i++ ) { - v = stdlib_base_round10f( x[ i ] ); - printf( "round10f(%f) = %f\n", x[ i ], v ); + v = stdlib_base_round10f( x[ i ] ); + printf( "round10f(%f) = %f\n", x[ i ], v ); } + return 0; } - diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h index 2476be54f28c..59ffdbf6e8fe 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h +++ b/lib/node_modules/@stdlib/math/base/special/round10f/include/stdlib/math/base/special/round10f.h @@ -20,13 +20,12 @@ #define STDLIB_MATH_BASE_SPECIAL_ROUND10F_H /* -* If C++, prevent name mangling... +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. */ #ifdef __cplusplus extern "C" { #endif -#include /* * Rounds a single-precision floating-point number to the nearest power of ten. @@ -40,4 +39,4 @@ float stdlib_base_round10f( const float x ); } #endif -#endif +#endif // !STDLIB_MATH_BASE_SPECIAL_ROUND10F_H diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js index 7ea2f073f429..91090a03142e 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/round10f/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Rounds a single-precision floating-point number to the nearest multiple of `10^n`. +* Rounds a single-precision floating-point number to the nearest power of `10` on a linear scale. * * @private * @param {number} x - input value diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json index 79275022f582..80a620fb8170 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json @@ -40,9 +40,7 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/roundf" + "@stdlib/math/base/special/powf" ] }, { @@ -60,9 +58,7 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/roundf" + "@stdlib/math/base/special/powf" ] }, { @@ -80,9 +76,7 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf", - "@stdlib/math/base/special/log10", - "@stdlib/math/base/special/roundf" + "@stdlib/math/base/special/powf" ] } ] diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c index b6f73655c8cc..bd65249e22bc 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/round10f/src/main.c @@ -17,12 +17,12 @@ */ #include "stdlib/math/base/special/round10f.h" -#include "stdlib/math/base/assert/is_nanf.h". -#include "stdlib/math/base/assert/is_infinitef.h". +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/assert/is_infinitef.h" #include "stdlib/math/base/special/absf.h" #include "stdlib/math/base/special/floorf.h" -#include "stdlib/math/base/special/powf.h". -#include "stdlib/math/base/special/log10.h". +#include "stdlib/math/base/special/powf.h" +#include "stdlib/math/base/special/log10.h" float stdlib_base_round10f( const float x ) { float ax; From 514945c226ec952aa554139870344fa088d72388 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 10 Jan 2026 17:04:19 +0000 Subject: [PATCH 22/22] fix: address review feedback for round10f C implementation and docs --- 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: na - 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: 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/round10f/manifest.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json index 80a620fb8170..896b972855de 100644 --- a/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/round10f/manifest.json @@ -40,7 +40,8 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10" ] }, { @@ -58,7 +59,8 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10" ] }, { @@ -76,7 +78,8 @@ "@stdlib/math/base/assert/is-infinitef", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/floorf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/log10" ] } ]