0.1.2 • Published 2 months ago

@stdlib/math-base-assert-is-nonnegative-integer v0.1.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

isNonNegativeInteger

NPM version Build Status Coverage Status

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

Installation

npm install @stdlib/math-base-assert-is-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

See Also


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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

@everything-registry/sub-chunk-868@stdlib/stats-base-dists-hypergeometric-logpmf@infinitebrahmanuniverse/nolb-_stdlib_m@stdlib/random-base-hypergeometric@stdlib/stats-base-dists-geometric-logpmf@stdlib/stats-base-dists-geometric-pmf@stdlib/stats-base-dists-hypergeometric-skewness@stdlib/stats-base-dists-hypergeometric-stdev@stdlib/stats-base-dists-hypergeometric-variance@stdlib/stats-base-dists-hypergeometric-cdf@stdlib/stats-base-dists-hypergeometric-kurtosis@stdlib/stats-base-dists-hypergeometric-mean@stdlib/stats-base-dists-hypergeometric-mode@stdlib/stats-base-dists-hypergeometric-pmf@stdlib/stats-base-dists-hypergeometric-quantile@stdlib/stats-base-dists-poisson-logpmf@stdlib/stats-base-dists-poisson-pmf@stdlib/stats-base-dists-negative-binomial-logpmf@stdlib/stats-base-dists-negative-binomial-pmf@stdlib/stats-base-dists-binomial-cdf@stdlib/stats-base-dists-binomial-entropy@stdlib/stats-base-dists-binomial-kurtosis@stdlib/stats-base-dists-binomial-logpmf@stdlib/stats-base-dists-binomial-mean@stdlib/stats-base-dists-binomial-median@stdlib/stats-base-dists-binomial-mgf@stdlib/stats-base-dists-binomial-mode@stdlib/stats-base-dists-binomial-pmf@stdlib/stats-base-dists-binomial-quantile@stdlib/stats-base-dists-binomial-skewness@stdlib/stats-base-dists-binomial-stdev@stdlib/stats-base-dists-binomial-variance@stdlib/stats-base-dists-erlang-logpdf@stdlib/stats-base-dists-erlang-mgf@stdlib/stats-base-dists-erlang-pdf@stdlib/stats-base-dists-erlang-quantile@stdlib/stats-base-dists-erlang-cdf@stdlib/math-base-special-bernoulli@stdlib/math-base-assert@stdlib/math-base-special-falling-factorial@stdlib/math-base-special-polygamma@zalastax/nolb-_stdlib_m
0.1.2

2 months ago

0.2.0

2 months ago

0.1.0

7 months ago

0.1.1

7 months ago

0.0.7

2 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago