diff --git a/CHANGELOG.md b/CHANGELOG.md
index a3426fa8a..5573696b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3309,6 +3309,29 @@ This release closes the following issue:
+
+
+##### BREAKING CHANGES
+
+- [`691e774`](https://github.com/stdlib-js/stdlib/commit/691e774930ab3d983998e53ad16dbf4bd5eb0c76): make base parameter compulsory in `math/base/special/floorsd`
+- [`691e774`](https://github.com/stdlib-js/stdlib/commit/691e774930ab3d983998e53ad16dbf4bd5eb0c76): The base parameter must now be provided explicitly.
+
+ - Previously, the base parameter had a default value of 10. Now it has to be supplied explicitly.
+ Before:
+ ```
+ var v = floorsd( 3.141592653589793, 5 );
+ // returns 3.1415
+ ```
+ After:
+ ```
+ var v = floorsd( 3.141592653589793, 5, 10 );
+ // returns 3.1415
+ ```
+
+
+
+
+
@@ -5184,6 +5207,29 @@ This release closes the following issue:
+
+
+### BREAKING CHANGES
+
+- [`691e774`](https://github.com/stdlib-js/stdlib/commit/691e774930ab3d983998e53ad16dbf4bd5eb0c76): make base parameter compulsory in `math/base/special/floorsd`
+- [`691e774`](https://github.com/stdlib-js/stdlib/commit/691e774930ab3d983998e53ad16dbf4bd5eb0c76): The base parameter must now be provided explicitly.
+
+ - Previously, the base parameter had a default value of 10. Now it has to be supplied explicitly.
+ Before:
+ ```
+ var v = floorsd( 3.141592653589793, 5 );
+ // returns 3.1415
+ ```
+ After:
+ ```
+ var v = floorsd( 3.141592653589793, 5, 10 );
+ // returns 3.1415
+ ```
+
+
+
+
+
### Closed Issues
@@ -5242,6 +5288,7 @@ A total of 29 people contributed to this release. Thank you to the following con
+- [`691e774`](https://github.com/stdlib-js/stdlib/commit/691e774930ab3d983998e53ad16dbf4bd5eb0c76) - **refactor:** make base parameter compulsory in `math/base/special/floorsd` [(##2617)](#2617) _(by Gunj Joshi)_
- [`dcb1b32`](https://github.com/stdlib-js/stdlib/commit/dcb1b32226e846c8c5219507bc30dce3bbcf19d2) - **feat:** add C implementation for `math/base/special/floorb` [(##2620)](#2620) _(by Gunj Joshi)_
- [`cc98b20`](https://github.com/stdlib-js/stdlib/commit/cc98b20ab91590c526896d547e447f107fc714aa) - **feat:** add C implementation for `math/base/special/factorial` [(##2618)](#2618 ) _(by Gunj Joshi)_
- [`1f99cd7`](https://github.com/stdlib-js/stdlib/commit/1f99cd7f06bd5e3027f29c6d816ea39e8624cab1) - **feat:** add C implementation for `math/base/special/floor10` [(##2619)](#2619) _(by Gunj Joshi)_
diff --git a/base/special/floorsd/README.md b/base/special/floorsd/README.md
index 652e23f69..180c18b0f 100644
--- a/base/special/floorsd/README.md
+++ b/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/base/special/floorsd/docs/repl.txt b/base/special/floorsd/docs/repl.txt
index 125f6a0c7..1d024c1f5 100644
--- a/base/special/floorsd/docs/repl.txt
+++ b/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/base/special/floorsd/docs/types/index.d.ts b/base/special/floorsd/docs/types/index.d.ts
index 38e8fe0d1..c0021c403 100644
--- a/base/special/floorsd/docs/types/index.d.ts
+++ b/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/base/special/floorsd/docs/types/test.ts b/base/special/floorsd/docs/types/test.ts
index 38c1dacd6..e85727f21 100644
--- a/base/special/floorsd/docs/types/test.ts
+++ b/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/base/special/floorsd/examples/index.js b/base/special/floorsd/examples/index.js
index 7664f02d9..b7d7b7245 100644
--- a/base/special/floorsd/examples/index.js
+++ b/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/base/special/floorsd/lib/index.js b/base/special/floorsd/lib/index.js
index c58847fcf..a12d3aca6 100644
--- a/base/special/floorsd/lib/index.js
+++ b/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/base/special/floorsd/lib/main.js b/base/special/floorsd/lib/main.js
index 64716e7da..9189dbe4c 100644
--- a/base/special/floorsd/lib/main.js
+++ b/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/base/special/floorsd/test/test.js b/base/special/floorsd/test/test.js
index fece08a16..6525ec4ff 100644
--- a/base/special/floorsd/test/test.js
+++ b/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' );