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
Alternatively,
- To load the package in a website via a
script
tag without installation and bundlers, use the ES Module available on theesm
branch. - If you are using Deno, visit the
deno
branch. - For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the
umd
branch.
The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.
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-2023. The Stdlib Authors.