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 @@ -20,7 +20,7 @@

var randu = require( '@stdlib/random/base/randu' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var pow = require( '@stdlib/math/base/special/pow' ); // TODO: replace with `powf` when available
var powf = require( '@stdlib/math/base/special/powf' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var BIAS = require( '@stdlib/constants/float32/exponent-bias' );
var frexpf = require( './../lib' );
Expand All @@ -42,12 +42,12 @@
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*76.0 ) - 38;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
f = frexpf( x );
if ( f[ 1 ] > BIAS ) {
v = f32( f[ 0 ] * f32( pow(2.0, f[1]-BIAS) ) * f32( pow(2.0, BIAS) ) );
v = f32( f[ 0 ] * f32( powf(2.0, f[1]-BIAS ) ) * f32( powf(2.0, BIAS ) ) );

Check warning on line 48 in lib/node_modules/@stdlib/math/base/special/frexpf/examples/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 83. Maximum allowed is 80
} else {
v = f32( f[ 0 ] * f32( pow( 2.0, f[ 1 ] ) ) );
v = f32( f[ 0 ] * f32( powf( 2.0, f[ 1 ] ) ) );
}
console.log( '%d = %d * 2^%d = %d', x, f[ 0 ], f[ 1 ], v );
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var PINF = require( '@stdlib/constants/float32/pinf' );
var BIAS = require( '@stdlib/constants/float32/exponent-bias' );
var randu = require( '@stdlib/random/base/randu' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var pow = require( '@stdlib/math/base/special/pow' ); // TODO: replace with `powf` when available
var powf = require( '@stdlib/math/base/special/powf' );
var absf = require( '@stdlib/math/base/special/absf' );
var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
Expand Down Expand Up @@ -144,15 +144,15 @@ tape( 'the returned normalized fraction and exponent satisfy the relation `x = f
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*76.0 ) - 38;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
out = new Float32Array( 2 );
f = frexpf( x, out, 1, 0 );
t.strictEqual( f, out, 'returns output array' );

if ( f[ 1 ] > BIAS ) {
f = f32( f[ 0 ] * pow( 2.0, BIAS ) * pow( 2.0, f[1]-BIAS ) );
f = f32( f[ 0 ] * powf( 2.0, BIAS ) * powf( 2.0, f[1]-BIAS ) );
} else {
f = f32( f[ 0 ] * pow( 2.0, f[ 1 ] ) );
f = f32( f[ 0 ] * powf( 2.0, f[ 1 ] ) );
}
t.strictEqual( f, x, 'returns expected value' );
}
Expand All @@ -176,7 +176,7 @@ tape( 'the absolute value of the normalized fraction is on the interval `[1/2,1)
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*74.0 ) - 37;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
out = new Float32Array( 2 );
f = frexpf( x, out, 1, 0 );
t.strictEqual( f, out, 'returns output array' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var PINF = require( '@stdlib/constants/float32/pinf' );
var BIAS = require( '@stdlib/constants/float32/exponent-bias' );
var randu = require( '@stdlib/random/base/randu' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var pow = require( '@stdlib/math/base/special/pow' ); // TODO: replace with `powf` when available
var powf = require( '@stdlib/math/base/special/powf' );
var absf = require( '@stdlib/math/base/special/absf' );
var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
Expand Down Expand Up @@ -130,13 +130,13 @@ tape( 'the returned normalized fraction and exponent satisfy the relation `x = f
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*76.0 ) - 38;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
f = frexpf( x );

if ( f[ 1 ] > BIAS ) {
f = f32( f[ 0 ] * pow( 2.0, BIAS ) * pow( 2.0, f[1]-BIAS ) );
f = f32( f[ 0 ] * powf( 2.0, BIAS ) * powf( 2.0, f[1]-BIAS ) );
} else {
f = f32( f[ 0 ] * pow( 2.0, f[ 1 ] ) );
f = f32( f[ 0 ] * powf( 2.0, f[ 1 ] ) );
}
t.strictEqual( f, x, 'returns expected value' );
}
Expand All @@ -159,7 +159,7 @@ tape( 'the absolute value of the normalized fraction is on the interval `[1/2,1)
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*74.0 ) - 37;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
f = frexpf( x );

// Compute the absolute value of the normalized fraction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var PINF = require( '@stdlib/constants/float32/pinf' );
var BIAS = require( '@stdlib/constants/float32/exponent-bias' );
var randu = require( '@stdlib/random/base/randu' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var pow = require( '@stdlib/math/base/special/pow' ); // TODO: replace with `powf` when available
var powf = require( '@stdlib/math/base/special/powf' );
var absf = require( '@stdlib/math/base/special/absf' );
var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
Expand Down Expand Up @@ -139,13 +139,13 @@ tape( 'the returned normalized fraction and exponent satisfy the relation `x = f
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*76.0 ) - 38;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
f = frexpf( x );

if ( f[ 1 ] > BIAS ) {
f = f32( f[ 0 ] * pow( 2.0, BIAS ) * pow( 2.0, f[1]-BIAS ) );
f = f32( f[ 0 ] * powf( 2.0, BIAS ) * powf( 2.0, f[1]-BIAS ) );
} else {
f = f32( f[ 0 ] * pow( 2.0, f[ 1 ] ) );
f = f32( f[ 0 ] * powf( 2.0, f[ 1 ] ) );
}
t.strictEqual( f, x, 'returns expected value' );
}
Expand All @@ -168,7 +168,7 @@ tape( 'the absolute value of the normalized fraction is on the interval `[1/2,1)
}
frac = f32( randu()*10.0 );
exp = roundf( randu()*74.0 ) - 37;
x = f32( sign * frac * f32( pow( 10.0, exp ) ) );
x = f32( sign * frac * f32( powf( 10.0, exp ) ) );
f = frexpf( x );

// Compute the absolute value of the normalized fraction:
Expand Down