Skip to content

Latest commit

 

History

History
115 lines (69 loc) · 2.42 KB

File metadata and controls

115 lines (69 loc) · 2.42 KB

add

Add two half-precision floating-point numbers.

Usage

var add = require( '@stdlib/number/float16/base/add' );

add( x, y )

Adds two half-precision floating-point numbers.

var v = add( -1.0, 5.0 );
// returns 4.0

v = add( 2.0, 5.0 );
// returns 7.0

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

v = add( -0.0, 0.0 );
// returns 0.0

v = add( NaN, NaN );
// returns NaN

Examples

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 add = require( '@stdlib/number/float16/base/add' );

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

logEachMap( 'x: %f, y: %f => %f', x, y, add );