Skip to content

Commit 9703163

Browse files
committed
refactor: as per suggested changes
1 parent df92e7a commit 9703163

File tree

5 files changed

+24
-21
lines changed

5 files changed

+24
-21
lines changed

lib/node_modules/@stdlib/number/float16/base/to-word/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var toWord = require( '@stdlib/number/float16/base/to-word' );
3232

3333
#### toWord( x )
3434

35-
Returns an unsigned 16-bit `integer` corresponding to the [IEEE 754][ieee754] binary representation of a [half-precision floating-point number][ieee754].
35+
Returns an unsigned 16-bit integer corresponding to the [IEEE 754][ieee754] binary representation of a [half-precision floating-point number][ieee754].
3636

3737
```javascript
3838
var float64ToFloat16 = require( '@stdlib/number/float64/base/to-float16' );

lib/node_modules/@stdlib/number/float16/base/to-word/benchmark/benchmark.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
2727
var pkg = require( './../package.json' ).name;
@@ -35,10 +35,11 @@ bench( pkg, function benchmark( b ) {
3535
var y;
3636
var i;
3737

38+
x = uniform( 100, -5.0e4, 5.0e4 );
39+
3840
b.tic();
3941
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*1.0e7 ) - 5.0e6;
41-
y = toWord( toFloat16( x ) );
42+
y = toWord( toFloat16( x[ i%x.length ] ) );
4243
if ( isnan( y ) ) {
4344
b.fail( 'should not return NaN' );
4445
}

lib/node_modules/@stdlib/number/float16/base/to-word/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
Parameters
77
----------
8-
x: float
9-
half-precision floating-point number.
8+
x: number
9+
Half-precision floating-point number.
1010

1111
Returns
1212
-------

lib/node_modules/@stdlib/number/float16/base/to-word/docs/types/test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@
1616
* limitations under the License.
1717
*/
1818

19-
import toWordf = require( './index' );
19+
import toWord = require( './index' );
2020

2121

2222
// TESTS //
2323

2424
// The function returns a number...
2525
{
26-
toWordf( 3.14 ); // $ExpectType number
27-
toWordf( -3.14 ); // $ExpectType number
26+
toWord( 3.14 ); // $ExpectType number
27+
toWord( -3.14 ); // $ExpectType number
2828
}
2929

3030
// The compiler throws an error if the function is provided a value other than a number...
3131
{
32-
toWordf( true ); // $ExpectError
33-
toWordf( false ); // $ExpectError
34-
toWordf( 'abc' ); // $ExpectError
35-
toWordf( [] ); // $ExpectError
36-
toWordf( {} ); // $ExpectError
37-
toWordf( ( x: number ): number => x ); // $ExpectError
32+
toWord( true ); // $ExpectError
33+
toWord( false ); // $ExpectError
34+
toWord( 'abc' ); // $ExpectError
35+
toWord( [] ); // $ExpectError
36+
toWord( {} ); // $ExpectError
37+
toWord( ( x: number ): number => x ); // $ExpectError
3838
}
3939

4040
// The compiler throws an error if the function is provided insufficient arguments...
4141
{
42-
toWordf(); // $ExpectError
42+
toWord(); // $ExpectError
4343
}

lib/node_modules/@stdlib/number/float16/base/to-word/examples/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@
1919
'use strict';
2020

2121
var float64ToFloat16 = require( '@stdlib/number/float64/base/to-float16' );
22-
var randu = require( '@stdlib/random/base/randu' );
22+
var uniform = require( '@stdlib/random/array/uniform' );
2323
var toWord = require( './../lib' );
2424

2525
var word;
26-
var f64;
2726
var f16;
27+
var x;
2828
var i;
2929

30+
// Generate an array of random numbers:
31+
x = uniform( 100, 0.0, 100.0 );
32+
3033
// Convert half-precision floating-point numbers to integers representing the binary literal...
3134
for ( i = 0; i < 1000; i++ ) {
32-
f64 = (randu()*100.0) - 50.0;
33-
f16 = float64ToFloat16( f64 );
35+
f16 = float64ToFloat16( x[ i%x.length ] );
3436
word = toWord( f16 );
35-
console.log( 'float64: %d => float16: %d => word: %d', f64, f16, word );
37+
console.log( 'float16: %d => word: %d', f16, word );
3638
}

0 commit comments

Comments
 (0)