Test if two half-precision floating-point numbers are the same value.
var isSameValue = require( '@stdlib/number/float16/base/assert/is-same-value' );Tests if two half-precision floating-point numbers a and b are the same value.
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
var bool = isSameValue( toFloat16( 3.14 ), toFloat16( 3.14 ) );
// returns true
bool = isSameValue( toFloat16( 5.0 ), toFloat16( 3.0 ) );
// returns falseIn contrast to the strict equality operator ===, the function distinguishes between +0 and -0 and treats NaNs as the same value.
var bool = ( 0.0 === -0.0 );
// returns true
bool = isSameValue( 0.0, -0.0 );
// returns false
bool = isSameValue( -0.0, -0.0 );
// returns true
bool = ( NaN === NaN );
// returns false
bool = isSameValue( NaN, NaN );
// returns true- The function implements the SameValue Algorithm as specified in ECMAScript 5.
var toFloat16 = require( '@stdlib/number/float64/base/to-float16' );
var isSameValue = require( '@stdlib/number/float16/base/assert/is-same-value' );
var bool = isSameValue( toFloat16( 3.14 ), toFloat16( 3.14 ) );
// returns true
bool = isSameValue( toFloat16( 0.0 ), toFloat16( 0.0 ) );
// returns true
bool = isSameValue( toFloat16( -0.0 ), toFloat16( 0.0 ) );
// returns false
bool = isSameValue( toFloat16( NaN ), toFloat16( NaN ) );
// returns true