isSquareNumber

Test if a value is a square number.

A square number is defined as an integer value which is the square of an integer.

Usage

var isSquareNumber = require( '@stdlib/assert/is-square-number' );

isSquareNumber( value )

Tests if a value is a square number.

var Number = require( '@stdlib/number/ctor' );

var bool = isSquareNumber( 4.0 );
// returns true

bool = isSquareNumber( new Number( 4.0 ) );
// returns true

bool = isSquareNumber( 3.14 );
// returns false

bool = isSquareNumber( -5.0 );
// returns false

bool = isSquareNumber( NaN );
// returns false

bool = isSquareNumber( null );
// returns false

isSquareNumber.isPrimitive( value )

Tests if a value is a primitive square number.

var Number = require( '@stdlib/number/ctor' );

var bool = isSquareNumber.isPrimitive( 4.0 );
// returns true

bool = isSquareNumber.isPrimitive( new Number( 4.0 ) );
// returns false

isSquareNumber.isObject( value )

Tests if a value is a Number object having a value which is a square number.

var Number = require( '@stdlib/number/ctor' );

var bool = isSquareNumber.isObject( 4.0 );
// returns false

bool = isSquareNumber.isObject( new Number( 4.0 ) );
// returns true

Examples

var Number = require( '@stdlib/number/ctor' );
var isSquareNumber = require( '@stdlib/assert/is-square-number' );

var bool = isSquareNumber( 4.0 );
// returns true

bool = isSquareNumber( new Number( 4.0 ) );
// returns true

bool = isSquareNumber( 0.0 );
// returns true

bool = isSquareNumber( 1.0 );
// returns true

bool = isSquareNumber( 3.14 );
// returns false

bool = isSquareNumber( -5.0 );
// returns false

bool = isSquareNumber( NaN );
// returns false

bool = isSquareNumber( '0.5' );
// returns false

bool = isSquareNumber( null );
// returns false
Did you find this page helpful?