Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ceil2( x ) {

// If provided the smallest subnormal, no rounding possible:
if ( p === MIN_EXP_SUBNORMAL ) {
return x;
return sign * x;
}
// Determine a power of two which rounds the input value toward positive infinity:
if ( sign === -1.0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ double stdlib_base_ceil2( const double x ) {

// If provided the smallest subnormal, no rounding possible:
if ( p == STDLIB_CONSTANT_FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL ) {
return xc;
return x;
}

// Determine a power of two which rounds the input value toward positive infinity:
Expand Down
6 changes: 6 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/ceil2/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ tape( 'the function returns the minimum double-precision floating-point value if
t.end();
});

tape( 'the function returns the negative minimum double-precision floating-point value if provided the negative minimum double-precision floating-point value', function test( t ) {
var v = ceil2( -SMALLEST_SUBNORMAL );
t.strictEqual( v, -SMALLEST_SUBNORMAL, 'returns negative smallest subnormal' );
t.end();
});

tape( 'the function overflows if provided a sufficiently large positive value', function test( t ) {
var x;
var v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ tape( 'the function returns the minimum double-precision floating-point value if
t.end();
});

tape( 'the function returns the negative minimum double-precision floating-point value if provided the negative minimum double-precision floating-point value', opts, function test( t ) {
var v = ceil2( -SMALLEST_SUBNORMAL );
t.strictEqual( v, -SMALLEST_SUBNORMAL, 'returns negative smallest subnormal' );
t.end();
});

tape( 'the function overflows if provided a sufficiently large positive value', opts, function test( t ) {
var x;
var v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function floor2( x ) {

// If provided the smallest subnormal, no rounding possible:
if ( p === MIN_EXP_SUBNORMAL ) {
return x;
return sign * x;
}
// Determine a power of two which rounds the input value toward negative infinity:
if ( sign === 1.0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ double stdlib_base_floor2( const double x ) {

// If provided the smallest subnormal, no rounding possible:
if ( p == STDLIB_CONSTANT_FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL ) {
return xc;
return x;
}
// Determine a power of two which rounds the input value toward negative infinity:
if ( sign == 1.0 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ tape( 'the function returns the minimum double-precision floating-point value if
t.end();
});

tape( 'the function returns the negative minimum double-precision floating-point value if provided the negative minimum double-precision floating-point value', function test( t ) {
var v = floor2( -SMALLEST_SUBNORMAL );
t.strictEqual( v, -SMALLEST_SUBNORMAL, 'returns negative smallest subnormal' );
t.end();
});

tape( 'the function overflows if provided a sufficiently large negative value', function test( t ) {
var x;
var v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ tape( 'the function returns the minimum double-precision floating-point value if
t.end();
});

tape( 'the function returns the negative minimum double-precision floating-point value if provided the negative minimum double-precision floating-point value', opts, function test( t ) {
var v = floor2( -SMALLEST_SUBNORMAL );
t.strictEqual( v, -SMALLEST_SUBNORMAL, 'returns negative smallest subnormal' );
t.end();
});

tape( 'the function overflows if provided a sufficiently large negative value', opts, function test( t ) {
var x;
var v;
Expand Down
Loading