@stdlib/assert-is-square-number
v0.2.2
Published
Test if a value is a square number.
Downloads
82
Readme
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.
Installation
npm install @stdlib/assert-is-square-number
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
See Also
@stdlib/assert-is-cube-number
: test if a value is a cube number.@stdlib/assert-is-integer
: test if a value is a number having an integer value.@stdlib/assert-is-number
: test if a value is a number.@stdlib/assert-is-triangular-number
: test if a value is a triangular number.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.