Skip to content
Open
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 @@ -38,7 +38,7 @@ var floor = require( '@stdlib/math/base/special/floor' );
var ldexp = require( '@stdlib/math/base/special/ldexp' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var MAXL10 = require( '@stdlib/constants/float64/max-base10-exponent' );
var MINL10 = require( '@stdlib/constants/float64/min-base10-exponent' );
var MINL10 = require( '@stdlib/constants/float64/min-base10-exponent-subnormal' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var polyvalP = require( './polyval_p.js' );
var polyvalQ = require( './polyval_q.js' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base10-exponent",
"@stdlib/constants/float64/min-base10-exponent-subnormal",
"@stdlib/constants/float64/nan"
]
},
Expand All @@ -62,7 +62,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base10-exponent",
"@stdlib/constants/float64/min-base10-exponent-subnormal",
"@stdlib/constants/float64/nan"
]
},
Expand All @@ -82,7 +82,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/floor",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base10-exponent",
"@stdlib/constants/float64/min-base10-exponent-subnormal",
"@stdlib/constants/float64/nan"
]
}
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/exp10/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "stdlib/math/base/special/ldexp.h"
#include "stdlib/math/base/assert/is_nan.h"
#include "stdlib/constants/float64/max_base10_exponent.h"
#include "stdlib/constants/float64/min_base10_exponent.h"
#include "stdlib/constants/float64/min_base10_exponent_subnormal.h"
#include "stdlib/constants/float64/pinf.h"
#include "stdlib/constants/float64/nan.h"
#include <stdint.h>
Expand Down Expand Up @@ -129,7 +129,7 @@ double stdlib_base_exp10( const double x ) {
if ( x > STDLIB_CONSTANT_FLOAT64_MAX_BASE10_EXPONENT ) {
return STDLIB_CONSTANT_FLOAT64_PINF;
}
if ( x < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT ) {
if ( x < STDLIB_CONSTANT_FLOAT64_MIN_BASE10_EXPONENT_SUBNORMAL ) {
return 0.0;
}
// Express 10^x = 10^g 2^n = 10^g 10^( n log10(2) ) = 10^( g + n log10(2) )
Expand Down
21 changes: 21 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/exp10/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var isPositiveZero = require( '@stdlib/assert/is-positive-zero' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var exp10 = require( './../lib' );


Expand Down Expand Up @@ -167,3 +168,23 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
t.strictEqual( isnan( val ), true, 'equals NaN' );
t.end();
});

tape( 'the function returns subnormal values for `x` in the subnormal range', function test( t ) {
var expected;
var x;
var v;
var i;

x = [ -308.5, -310.0, -320.0, -323.5 ];
expected = [
3.16227766016838e-309,
1e-310,
1e-320,
5e-324
];
for ( i = 0; i < x.length; i++ ) {
v = exp10( x[ i ] );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,23 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
t.strictEqual( isnan( val ), true, 'equals NaN' );
t.end();
});

tape( 'the function returns subnormal values for `x` in the subnormal range', opts, function test( t ) {
var expected;
var x;
var v;
var i;

x = [ -308.5, -310.0, -320.0, -323.5 ];
expected = [
3.16227766016838e-309,
1e-310,
1e-320,
5e-324
];
for ( i = 0; i < x.length; i++ ) {
v = exp10( x[ i ] );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/exp2/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

'use strict';

// TODO: replace with TOMS (Openlibm) algo (updating license header and long comment)

Check warning on line 35 in lib/node_modules/@stdlib/math/base/special/exp2/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: replace with TOMS (Openlibm) algo...'

// MODULES //

var FLOAT64_MAX_BASE2_EXPONENT = require( '@stdlib/constants/float64/max-base2-exponent' ); // eslint-disable-line id-length
var FLOAT64_MIN_BASE2_EXPONENT = require( '@stdlib/constants/float64/min-base2-exponent' ); // eslint-disable-line id-length
var FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL = require( '@stdlib/constants/float64/min-base2-exponent-subnormal' ); // eslint-disable-line id-length
var round = require( '@stdlib/math/base/special/round' );
var ldexp = require( '@stdlib/math/base/special/ldexp' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
Expand Down Expand Up @@ -104,7 +104,8 @@
if ( x > FLOAT64_MAX_BASE2_EXPONENT ) {
return PINF;
}
if ( x < FLOAT64_MIN_BASE2_EXPONENT ) {
// Note: values on the interval `(-1075, -1074)` round to the smallest subnormal...
if ( x <= FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL-1 ) {
return 0.0;
}
// Separate into integer and fractional parts...
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/math/base/special/exp2/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/round",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base2-exponent"
"@stdlib/constants/float64/min-base2-exponent-subnormal"
]
},
{
Expand All @@ -64,7 +64,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/round",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base2-exponent"
"@stdlib/constants/float64/min-base2-exponent-subnormal"
]
},
{
Expand All @@ -84,7 +84,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/round",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base2-exponent"
"@stdlib/constants/float64/min-base2-exponent-subnormal"
]
},
{
Expand All @@ -104,7 +104,7 @@
"@stdlib/constants/float64/pinf",
"@stdlib/math/base/special/round",
"@stdlib/math/base/special/ldexp",
"@stdlib/constants/float64/min-base2-exponent"
"@stdlib/constants/float64/min-base2-exponent-subnormal"
]
}
]
Expand Down
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/exp2/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include "stdlib/math/base/special/exp2.h"
#include "stdlib/constants/float64/max_base2_exponent.h"
#include "stdlib/constants/float64/min_base2_exponent.h"
#include "stdlib/constants/float64/min_base2_exponent_subnormal.h"
#include "stdlib/math/base/special/round.h"
#include "stdlib/math/base/special/ldexp.h"
#include "stdlib/math/base/assert/is_nan.h"
Expand Down Expand Up @@ -128,7 +128,8 @@ double stdlib_base_exp2( const double x ) {
if ( x > STDLIB_CONSTANT_FLOAT64_MAX_BASE2_EXPONENT ) {
return STDLIB_CONSTANT_FLOAT64_PINF;
}
if ( x < STDLIB_CONSTANT_FLOAT64_MIN_BASE2_EXPONENT ) {
// Note: values on the interval `(-1075, -1074)` round to the smallest subnormal...
if ( x <= STDLIB_CONSTANT_FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL-1 ) {
return 0.0;
}

Expand Down
20 changes: 20 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/exp2/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ tape( 'the function returns `+infinity` for very large `x`', function test( t )
});

tape( 'the function returns `0.0` for negative large `x`', function test( t ) {
t.strictEqual( exp2( -1075.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1100.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1200.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1300.0 ), 0.0, 'equals 0' );
Expand Down Expand Up @@ -168,3 +169,22 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) {
t.strictEqual( isnan( val ), true, 'equals NaN' );
t.end();
});

tape( 'the function returns subnormal values for `x` in the subnormal range', function test( t ) {
var expected;
var x;
var v;
var i;

x = [ -1023.5, -1050.0, -1074.0 ];
expected = [
7.866824069956793e-309,
8.289046e-317,
5e-324
];
for ( i = 0; i < x.length; i++ ) {
v = exp2( x[ i ] );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ tape( 'the function returns `+infinity` for very large `x`', opts, function test
});

tape( 'the function returns `0.0` for negative large `x`', opts, function test( t ) {
t.strictEqual( exp2( -1075.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1100.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1200.0 ), 0.0, 'equals 0' );
t.strictEqual( exp2( -1300.0 ), 0.0, 'equals 0' );
Expand Down Expand Up @@ -177,3 +178,22 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) {
t.strictEqual( isnan( val ), true, 'equals NaN' );
t.end();
});

tape( 'the function returns subnormal values for `x` in the subnormal range', opts, function test( t ) {
var expected;
var x;
var v;
var i;

x = [ -1023.5, -1050.0, -1074.0 ];
expected = [
7.866824069956793e-309,
8.289046e-317,
5e-324
];
for ( i = 0; i < x.length; i++ ) {
v = exp2( x[ i ] );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});
Loading