Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jul 21, 2024
1 parent d2e4c5e commit 5316fe8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5515,6 +5515,7 @@ A total of 29 people contributed to this release. Thank you to the following con

<details>

- [`6a0cbd9`](https://github.com/stdlib-js/stdlib/commit/6a0cbd9c10f0895d795be449fe1ea2a456f2683a) - **test:** fix tests for native implementation [(#2641)](https://github.com/stdlib-js/stdlib/pull/2641) _(by Gunj Joshi)_
- [`ead1c3b`](https://github.com/stdlib-js/stdlib/commit/ead1c3b780527d8068d9c076e85688be94d53775) - **chore:** update package meta data [(#2640)](https://github.com/stdlib-js/stdlib/pull/2640) _(by stdlib-bot, Athan Reines)_
- [`5df976a`](https://github.com/stdlib-js/stdlib/commit/5df976abacaaf3082890fa852e40edfdf1b79f4b) - **feat:** update namespace TypeScript declarations [(#2637)](https://github.com/stdlib-js/stdlib/pull/2637) _(by stdlib-bot, Philipp Burckhardt)_
- [`854b793`](https://github.com/stdlib-js/stdlib/commit/854b793ecdcc540067d9989f4c14e34fb9b736bb) - **feat:** add C implementation for `math/base/special/ceilsd` _(by Gunj Joshi, Philipp Burckhardt)_
Expand Down
2 changes: 1 addition & 1 deletion base/special/ceilsd/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Number of significant figures. Must be greater than 0.

b: integer
Base. Must be greater than 0. Default: 10.
Base. Must be greater than 0.

Returns
-------
Expand Down
14 changes: 0 additions & 14 deletions base/special/ceilsd/docs/types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ import ceilsd = require( './index' );

// The compiler throws an error if the function is provided values other than numbers...
{
ceilsd( true, 3 ); // $ExpectError
ceilsd( false, 2 ); // $ExpectError
ceilsd( '5', 1 ); // $ExpectError
ceilsd( [], 1 ); // $ExpectError
ceilsd( {}, 2 ); // $ExpectError
ceilsd( ( x: number ): number => x, 2 ); // $ExpectError

ceilsd( 9, true ); // $ExpectError
ceilsd( 9, false ); // $ExpectError
ceilsd( 5, '5' ); // $ExpectError
ceilsd( 8, [] ); // $ExpectError
ceilsd( 9, {} ); // $ExpectError
ceilsd( 8, ( x: number ): number => x ); // $ExpectError

ceilsd( true, 3, 2 ); // $ExpectError
ceilsd( false, 2, 2 ); // $ExpectError
ceilsd( '5', 1, 2 ); // $ExpectError
Expand Down
6 changes: 3 additions & 3 deletions base/special/ceilsd/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ double stdlib_base_ceilsd( const double x, const int32_t n, const int32_t b ) {
} else if ( b == 2 ) {
exp = stdlib_base_float64_exponent( stdlib_base_abs( x ) );
} else {
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( b );
exp = stdlib_base_ln( stdlib_base_abs( x ) ) / stdlib_base_ln( (double)b );
}
exp = stdlib_base_floor( exp - n + 1.0 );
s = stdlib_base_pow( b, stdlib_base_abs( exp ) );
exp = stdlib_base_floor( exp - (double)n + 1.0 );
s = stdlib_base_pow( (double)b, stdlib_base_abs( exp ) );

// Check for overflow:
if ( stdlib_base_is_infinite( s ) ) {
Expand Down
45 changes: 27 additions & 18 deletions base/special/ceilsd/test/test.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,78 @@

// MODULES //

var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var PI = require( '@stdlib/constants/float64/pi' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var isnan = require( './../../../../base/assert/is-nan' );
var isNegativeZero = require( './../../../../base/assert/is-negative-zero' );
var isPositiveZero = require( './../../../../base/assert/is-positive-zero' );
var ceilsd = require( './../lib' );
var tryRequire = require( '@stdlib/utils/try-require' );


// VARIABLES //

var ceilsd = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( ceilsd instanceof Error )
};


// TESTS //

tape( 'main export is a function', function test( t ) {
tape( 'main export is a function', opts, function test( t ) {
t.ok( true, __filename );
t.strictEqual( typeof ceilsd, 'function', 'main export is a function' );
t.end();
});

tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
var v;

v = ceilsd( NaN, 2, 10 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if provided `n < 1`', function test( t ) {
tape( 'the function returns `NaN` if provided `n < 1`', opts, function test( t ) {
var v;

v = ceilsd( PI, 0, 10 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = ceilsd( PI, -1, 10 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `NaN` if provided `b <= 0`', function test( t ) {
tape( 'the function returns `NaN` if provided `b <= 0`', opts, function test( t ) {
var v;

v = ceilsd( PI, 2, 0 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

v = ceilsd( PI, 2, -1 );
t.strictEqual( isnan( v ), true, 'returns NaN' );
t.strictEqual( isnan( v ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) {
tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) {
var v = ceilsd( PINF, 5, 10 );
t.strictEqual( v, PINF, 'returns +infinity' );
t.end();
});

tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) {
tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) {
var v = ceilsd( NINF, 3, 10 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.end();
});

tape( 'the function returns `-0` if provided `-0`', function test( t ) {
tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) {
var v;

v = ceilsd( -0.0, 1, 10 );
Expand All @@ -94,7 +103,7 @@ tape( 'the function returns `-0` if provided `-0`', function test( t ) {
t.end();
});

tape( 'the function returns `+0` if provided `+0`', function test( t ) {
tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) {
var v;

v = ceilsd( 0.0, 1, 10 );
Expand All @@ -106,7 +115,7 @@ tape( 'the function returns `+0` if provided `+0`', function test( t ) {
t.end();
});

tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', function test( t ) {
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 10)', opts, function test( t ) {
t.strictEqual( ceilsd( PI, 1, 10 ), 4.0, 'returns expected value' );
t.strictEqual( ceilsd( -PI, 1, 10 ), -3.0, 'returns expected value' );
t.strictEqual( ceilsd( PI, 2, 10 ), 3.2, 'returns expected value' );
Expand All @@ -123,7 +132,7 @@ tape( 'the function supports rounding a numeric value with a specified number of
t.end();
});

tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', function test( t ) {
tape( 'the function supports rounding a numeric value with a specified number of significant figures (base 2)', opts, function test( t ) {
t.strictEqual( ceilsd( 0.0313, 1, 2 ), 0.0625, 'returns expected value' );
t.strictEqual( ceilsd( 0.0313, 2, 2 ), 0.046875, 'returns expected value' );
t.strictEqual( ceilsd( 0.0313, 3, 2 ), 0.0390625, 'returns expected value' );
Expand All @@ -141,13 +150,13 @@ tape( 'the function supports rounding a numeric value with a specified number of
t.end();
});

tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', function test( t ) {
tape( 'the function supports rounding a numeric value with a specified number of significant figures using an arbitrary base', opts, function test( t ) {
t.strictEqual( ceilsd( 0.0313, 1, 16 ), 0.03515625, 'returns expected value' );
t.strictEqual( ceilsd( 0.0313, 5, 16 ), 0.03130000829696655, 'returns expected value' );
t.end();
});

tape( 'if the function encounters overflow, the function returns the input value', function test( t ) {
tape( 'if the function encounters overflow, the function returns the input value', opts, function test( t ) {
var x;
var v;

Expand Down

0 comments on commit 5316fe8

Please sign in to comment.