diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/README.md b/lib/node_modules/@stdlib/math/base/special/floorsd/README.md index c8b3ed34fac..3f9b3b9b1ff 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/README.md +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/README.md @@ -30,25 +30,21 @@ limitations under the License. var floorsd = require( '@stdlib/math/base/special/floorsd' ); ``` -#### floorsd( x, n\[, b] ) +#### floorsd( x, n, b ) Rounds a `numeric` value to the nearest `number` toward negative infinity with `n` significant figures. ```javascript -var v = floorsd( 3.141592653589793, 5 ); +var v = floorsd( 3.141592653589793, 5, 10 ); // returns 3.1415 -v = floorsd( 3.141592653589793, 1 ); +v = floorsd( 3.141592653589793, 1, 10 ); // returns 3.0 -v = floorsd( 12368.0, 2 ); +v = floorsd( 12368.0, 2, 10 ); // returns 12000.0 -``` - -The default base is `10` (decimal). To round using a different base, provide a third argument. -```javascript -var v = floorsd( 0.0313, 2, 2 ); +v = floorsd( 0.0313, 2, 2 ); // returns 0.03125 ``` @@ -78,7 +74,7 @@ var i; for ( i = 0; i < 100; i++ ) { x = (randu()*10000.0) - 5000.0; - y = floorsd( x, 5 ); + y = floorsd( x, 5, 10 ); console.log( 'x: %d. Rounded: %d.', x, y ); } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/repl.txt index 125f6a0c739..1d024c1f594 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( x, n[, b] ) +{{alias}}( x, n, b ) Rounds a numeric value to the nearest number toward negative infinity with `n` significant figures. @@ -11,8 +11,8 @@ n: integer Number of significant figures. Must be greater than 0. - b: integer (optional) - Base. Must be greater than 0. Default: 10. + b: integer + Base. Must be greater than 0. Returns ------- @@ -21,11 +21,11 @@ Examples -------- - > var y = {{alias}}( 3.14159, 5 ) + > var y = {{alias}}( 3.14159, 5, 10 ) 3.1415 - > y = {{alias}}( 3.14159, 1 ) + > y = {{alias}}( 3.14159, 1, 10 ) 3.0 - > y = {{alias}}( 12368.0, 2 ) + > y = {{alias}}( 12368.0, 2, 10 ) 12000.0 > y = {{alias}}( 0.0313, 2, 2 ) 0.03125 diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/index.d.ts index 38e8fe0d19f..c0021c40311 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/index.d.ts @@ -23,26 +23,26 @@ * * @param x - input value * @param n - number of significant figures -* @param b - base (default: 10) +* @param b - base * @returns rounded value * * @example -* var v = floorsd( 3.141592653589793, 5 ); +* var v = floorsd( 3.141592653589793, 5, 10 ); * // returns 3.1415 * * @example -* var v = floorsd( 3.141592653589793, 1 ); +* var v = floorsd( 3.141592653589793, 1, 10 ); * // returns 3.0 * * @example -* var v = floorsd( 12368.0, 2 ); +* var v = floorsd( 12368.0, 2, 10 ); * // returns 12000.0 * * @example * var v = floorsd( 0.0313, 2, 2 ); * // returns 0.03125 */ -declare function floorsd( x: number, n: number, b?: number ): number; +declare function floorsd( x: number, n: number, b: number ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/test.ts index 38c1dacd6e6..e85727f2182 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/docs/types/test.ts @@ -24,7 +24,6 @@ import floorsd = require( './index' ); // The function returns a number... { floorsd( 3.141592653589793, 4, 10 ); // $ExpectType number - floorsd( 3.141592653589793, 4 ); // $ExpectType number } // The compiler throws an error if the function is provided values other than numbers... diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/examples/index.js b/lib/node_modules/@stdlib/math/base/special/floorsd/examples/index.js index 7664f02d93d..b7d7b724573 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/examples/index.js @@ -27,6 +27,6 @@ var i; for ( i = 0; i < 100; i++ ) { x = (randu()*10000.0) - 5000.0; - y = floorsd( x, 5 ); + y = floorsd( x, 5, 10 ); console.log( 'x: %d. Rounded: %d.', x, y ); } diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/lib/index.js b/lib/node_modules/@stdlib/math/base/special/floorsd/lib/index.js index c58847fcfed..a12d3aca656 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/lib/index.js @@ -26,13 +26,13 @@ * @example * var floorsd = require( '@stdlib/math/base/special/floorsd' ); * -* var v = floorsd( 3.141592653589793, 5 ); +* var v = floorsd( 3.141592653589793, 5, 10 ); * // returns 3.1415 * -* v = floorsd( 3.141592653589793, 1 ); +* v = floorsd( 3.141592653589793, 1, 10 ); * // returns 3.0 * -* v = floorsd( 12368.0, 2 ); +* v = floorsd( 12368.0, 2, 10 ); * // returns 12000.0 * * v = floorsd( 0.0313, 2, 2 ); diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/lib/main.js b/lib/node_modules/@stdlib/math/base/special/floorsd/lib/main.js index 8931ff0e05b..03f6b69e0c4 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/lib/main.js @@ -37,19 +37,19 @@ var exponent = require( '@stdlib/number/float64/base/exponent' ); * * @param {number} x - input value * @param {PositiveInteger} n - number of significant figures -* @param {PositiveInteger} [b=10] - base +* @param {PositiveInteger} b - base * @returns {number} rounded value * * @example -* var v = floorsd( 3.141592653589793, 5 ); +* var v = floorsd( 3.141592653589793, 5, 10 ); * // returns 3.1415 * * @example -* var v = floorsd( 3.141592653589793, 1 ); +* var v = floorsd( 3.141592653589793, 1, 10 ); * // returns 3.0 * * @example -* var v = floorsd( 12368.0, 2 ); +* var v = floorsd( 12368.0, 2, 10 ); * // returns 12000.0 * * @example @@ -57,7 +57,6 @@ var exponent = require( '@stdlib/number/float64/base/exponent' ); * // returns 0.03125 */ function floorsd( x, n, b ) { - var base; var exp; var s; var y; @@ -69,32 +68,27 @@ function floorsd( x, n, b ) { ) { return NaN; } - if ( arguments.length > 2 ) { - if ( - isnan( b ) || - b <= 0 || - isInfinite( b ) - ) { - return NaN; - } - base = b; - } else { - base = 10; + if ( + isnan( b ) || + b <= 0 || + isInfinite( b ) + ) { + return NaN; } if ( isInfinite( x ) || x === 0.0 ) { return x; } - if ( base === 10 ) { + if ( b === 10 ) { exp = log10( abs( x ) ); } - else if ( base === 2 ) { + else if ( b === 2 ) { exp = exponent( abs( x ) ); } else { - exp = ln( abs(x) ) / ln( base ); + exp = ln( abs(x) ) / ln( b ); } exp = floor( exp - n + 1.0 ); - s = pow( base, abs( exp ) ); + s = pow( b, abs( exp ) ); // Check for overflow: if ( isInfinite( s ) ) { diff --git a/lib/node_modules/@stdlib/math/base/special/floorsd/test/test.js b/lib/node_modules/@stdlib/math/base/special/floorsd/test/test.js index 5860acabba7..bd78fe64759 100644 --- a/lib/node_modules/@stdlib/math/base/special/floorsd/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/floorsd/test/test.js @@ -41,13 +41,13 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v; - v = floorsd( NaN, 2 ); + v = floorsd( NaN, 2, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = floorsd( 12368.0, NaN ); + v = floorsd( 12368.0, NaN, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = floorsd( NaN, NaN ); + v = floorsd( NaN, NaN, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); v = floorsd( NaN, NaN, 10 ); @@ -68,10 +68,10 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { tape( 'the function returns `NaN` if provided `n = +-infinity`', function test( t ) { var v; - v = floorsd( PI, PINF ); + v = floorsd( PI, PINF, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = floorsd( PI, NINF ); + v = floorsd( PI, NINF, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); @@ -80,10 +80,10 @@ tape( 'the function returns `NaN` if provided `n = +-infinity`', function test( tape( 'the function returns `NaN` if provided `n < 1`', function test( t ) { var v; - v = floorsd( PI, 0 ); + v = floorsd( PI, 0, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); - v = floorsd( PI, -1 ); + v = floorsd( PI, -1, 10 ); t.strictEqual( isnan( v ), true, 'returns NaN' ); t.end(); @@ -114,13 +114,13 @@ tape( 'the function returns `NaN` if provided `b <= 0`', function test( t ) { }); tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { - var v = floorsd( PINF, 5 ); + var v = floorsd( PINF, 5, 10 ); t.strictEqual( v, PINF, 'returns +infinity' ); t.end(); }); tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) { - var v = floorsd( NINF, 3 ); + var v = floorsd( NINF, 3, 10 ); t.strictEqual( v, NINF, 'returns -infinity' ); t.end(); }); @@ -128,10 +128,10 @@ tape( 'the function returns `-infinity` if provided `-infinity`', function test( tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v; - v = floorsd( -0.0, 1 ); + v = floorsd( -0.0, 1, 10 ); t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); - v = floorsd( -0.0, 2 ); + v = floorsd( -0.0, 2, 10 ); t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); t.end(); @@ -140,32 +140,15 @@ tape( 'the function returns `-0` if provided `-0`', function test( t ) { tape( 'the function returns `+0` if provided `+0`', function test( t ) { var v; - v = floorsd( 0.0, 1 ); + v = floorsd( 0.0, 1, 10 ); t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); - v = floorsd( +0.0, 2 ); + v = floorsd( +0.0, 2, 10 ); t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); t.end(); }); -tape( 'the function supports rounding a numeric value with a specified number of significant figures', function test( t ) { - t.strictEqual( floorsd( PI, 1 ), 3.0, 'returns expected value' ); - t.strictEqual( floorsd( -PI, 1 ), -4.0, 'returns expected value' ); - t.strictEqual( floorsd( PI, 2 ), 3.1, 'returns expected value' ); - t.strictEqual( floorsd( -PI, 2 ), -3.2, 'returns expected value' ); - t.strictEqual( floorsd( PI, 3 ), 3.14, 'returns expected value' ); - t.strictEqual( floorsd( -PI, 3 ), -3.15, 'returns expected value' ); - t.strictEqual( floorsd( PI, 5 ), 3.1415, 'returns expected value' ); - t.strictEqual( floorsd( -PI, 5 ), -3.1416, 'returns expected value' ); - t.strictEqual( floorsd( 0.0, 2 ), 0.0, 'returns expected value' ); - t.strictEqual( floorsd( 12368.0, 3 ), 12300.0, 'returns expected value' ); - t.strictEqual( floorsd( -12368.0, 3 ), -12400.0, 'returns expected value' ); - t.strictEqual( floorsd( 12368.0, 2 ), 12000.0, 'returns expected value' ); - t.strictEqual( floorsd( -12368.0, 2 ), -13000.0, 'returns expected value' ); - t.end(); -}); - tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', function test( t ) { t.strictEqual( floorsd( PI, 1, 10 ), 3.0, 'returns expected value' ); t.strictEqual( floorsd( -PI, 1, 10 ), -4.0, 'returns expected value' );