Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e8eb608
feat: add number/float16/base/div
Lokeshranjan8 Dec 31, 2025
05046ef
Update copyright year from 2023 to 2025
Lokeshranjan8 Dec 31, 2025
d8223e6
Clean up package.json by removing gypfile and directories
Lokeshranjan8 Dec 31, 2025
e3bf011
Update lib/node_modules/@stdlib/number/float16/base/div/lib/main.js
Lokeshranjan8 Jan 1, 2026
fac1a34
Update lib/node_modules/@stdlib/number/float16/base/div/README.md
Lokeshranjan8 Jan 1, 2026
87007ea
bench: generate half-precision inputs using uniform distribution
Lokeshranjan8 Jan 1, 2026
a213d16
bench: wrap toFloat16 with naryFunction in map
Lokeshranjan8 Jan 1, 2026
7f4dee6
Revise div function documentation for clarity
Lokeshranjan8 Jan 1, 2026
316495f
Update lib/node_modules/@stdlib/number/float16/base/div/package.json
Lokeshranjan8 Jan 2, 2026
d0e2844
Update lib/node_modules/@stdlib/number/float16/base/div/package.json
Lokeshranjan8 Jan 2, 2026
d9b54f1
Update lib/node_modules/@stdlib/number/float16/base/div/examples/inde…
Lokeshranjan8 Jan 8, 2026
9ebade0
Update lib/node_modules/@stdlib/number/float16/base/div/examples/inde…
Lokeshranjan8 Jan 8, 2026
1aee25c
Update lib/node_modules/@stdlib/number/float16/base/div/README.md
Lokeshranjan8 Jan 8, 2026
ee0a4db
Update lib/node_modules/@stdlib/number/float16/base/div/test/test.js
Lokeshranjan8 Jan 8, 2026
7284e19
Update lib/node_modules/@stdlib/number/float16/base/div/docs/types/in…
Lokeshranjan8 Jan 12, 2026
3cfe186
Update lib/node_modules/@stdlib/number/float16/base/div/package.json
Lokeshranjan8 Jan 16, 2026
33139bd
Update test.js
Lokeshranjan8 Jan 16, 2026
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
115 changes: 115 additions & 0 deletions lib/node_modules/@stdlib/number/float16/base/div/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# div

> Divide two half-precision floating-point numbers.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var div = require( '@stdlib/number/float16/base/div' );
```

#### div( x, y )

Divides two half-precision floating-point numbers.

```javascript
var v = div( -1.0, 5.0 );
// returns ~-0.2

v = div( 2.0, 5.0 );
// returns ~0.4

v = div( 0.0, 5.0 );
// returns 0.0

v = div( -0.0, 5.0 );
// returns -0.0

v = div( NaN, NaN );
// returns NaN
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
var uniform = require( '@stdlib/random/array/uniform' );
var map = require( '@stdlib/array/base/map' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var div = require( '@stdlib/number/float16/base/div' );

var x = map( uniform( 100, -50.0, 50.0 ), toFloat16 );
var y = map( uniform( 100, -50.0, 50.0 ), toFloat16 );

logEachMap( 'x: %0.4f, y: %0.4f => div: %0.4f', x, y, div );
```

</section>

<!-- /.examples -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var map = require( '@stdlib/array/base/map' );
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
var isnan = require( '@stdlib/math/base/assert/is-nanf' );
var naryFunction = require( '@stdlib/utils/nary-function' );
var pkg = require( './../package.json' ).name;
var div = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var out;
var x;
var y;
var i;

x = map( uniform( 100, -100, 100 ), naryFunction( toFloat16, 1 ) );
y = map( uniform( 100, -100, 100 ), naryFunction( toFloat16, 1 ) );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = div( x[ i%x.length ], y[ i%y.length ] );
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( out ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
33 changes: 33 additions & 0 deletions lib/node_modules/@stdlib/number/float16/base/div/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

{{alias}}( x, y )
Divides two half-precision floating-point numbers.

Parameters
----------
x: number
First input value (dividend).

y: number
Second input value (divisor).

Returns
-------
z: number
Result.

Examples
--------
> var v = {{alias}}( -1.0, 5.0 )
~-0.2
> v = {{alias}}( 2.0, 5.0 )
~0.4
> v = {{alias}}( 0.0, 5.0 )
0.0
> v = {{alias}}( -0.0, 5.0 )
-0.0
> v = {{alias}}( NaN, NaN )
NaN

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/**
* Divides two half-precision floating-point numbers.
*
* @param x - first input value
* @param y - second input value
* @returns result
*
* @example
* var v = div( -1.0, 5.0 );
* // returns ~-0.2
*
* @example
* var v = div( 2.0, 5.0 );
* // returns ~0.4
*
* @example
* var v = div( 0.0, 5.0 );
* // returns 0.0
*
* @example
* var v = div( -0.0, 5.0 );
* // returns -0.0
*
* @example
* var v = div( NaN, NaN );
* // returns NaN
*/
declare function div( x: number, y: number ): number;


// EXPORTS //

export = div;
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import div = require( './index' );


// TESTS //

// The function returns a number...
{
div( 8.0, 8.0 ); // $ExpectType number
}

// The compiler throws an error if the function is provided a first argument which is not a number...
{
div( true, 5.0 ); // $ExpectError
div( false, 5.0 ); // $ExpectError
div( null, 5.0 ); // $ExpectError
div( undefined, 5.0 ); // $ExpectError
div( '5', 5.0 ); // $ExpectError
div( [], 5.0 ); // $ExpectError
div( {}, 5.0 ); // $ExpectError
div( ( x: number ): number => x, 5.0 ); // $ExpectError
}

// The compiler throws an error if the function is provided a second argument which is not a number...
{
div( 5.0, true ); // $ExpectError
div( 5.0, false ); // $ExpectError
div( 5.0, null ); // $ExpectError
div( 5.0, undefined ); // $ExpectError
div( 5.0, '5' ); // $ExpectError
div( 5.0, [] ); // $ExpectError
div( 5.0, {} ); // $ExpectError
div( 5.0, ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
div(); // $ExpectError
div( 5.0 ); // $ExpectError
div( 5.0, 5.0, 5.0 ); // $ExpectError
}
30 changes: 30 additions & 0 deletions lib/node_modules/@stdlib/number/float16/base/div/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
var uniform = require( '@stdlib/random/array/uniform' );
var map = require( '@stdlib/array/base/map' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var div = require( './../lib' );

var x = map( uniform( 100, -50.0, 50.0 ), toFloat16 );
var y = map( uniform( 100, -50.0, 50.0 ), toFloat16 );

logEachMap( 'x: %0.4f, y: %0.4f => div: %0.4f', x, y, div );
Loading