time-to-botec/squiggle/node_modules/@stdlib/math/base/assert/is-nonnegative-integer
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

isNonNegativeInteger

Test if a finite double-precision floating-point number is a nonnegative integer.

Usage

var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );

isNonNegativeInteger( x )

Tests if a finite double-precision floating-point number is a nonnegative integer.

var bool = isNonNegativeInteger( 1.0 );
// returns true

bool = isNonNegativeInteger( 0.0 );
// returns true

bool = isNonNegativeInteger( -10.0 );
// returns false

Notes

  • The function assumes a finite number. If provided positive infinity, the function will return true, when, in fact, the result is undefined. If x can be infinite, wrap the implementation as follows:

    function check( x ) {
        return (
            x < Infinity &&
            isNonNegativeInteger( x )
        );
    }
    
    var bool = check( Infinity );
    // returns false
    
  • The function does not distinguish between positive and negative zero.

    var bool = isNonNegativeInteger( 0.0 );
    // returns true
    
    bool = isNonNegativeInteger( -0.0 );
    // returns true
    

Examples

var isNonNegativeInteger = require( '@stdlib/math/base/assert/is-nonnegative-integer' );

var bool = isNonNegativeInteger( 5.0 );
// returns true

bool = isNonNegativeInteger( 0.0 );
// returns true

bool = isNonNegativeInteger( -1.0 );
// returns false

bool = isNonNegativeInteger( 3.14 );
// returns false

bool = isNonNegativeInteger( NaN );
// returns false