JSPM

@stdlib/math-base-assert-is-positive-integer

0.0.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3670
  • Score
    100M100P100Q150799F
  • License Apache-2.0

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

Package Exports

  • @stdlib/math-base-assert-is-positive-integer
  • @stdlib/math-base-assert-is-positive-integer/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/math-base-assert-is-positive-integer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

isPositiveInteger

NPM version Build Status Coverage Status

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

Installation

npm install @stdlib/math-base-assert-is-positive-integer

Usage

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

isPositiveInteger( x )

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

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

bool = isPositiveInteger( 0.0 );
// returns false

bool = isPositiveInteger( -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 &&
            isPositiveInteger( x )
        );
    }
    
    var bool = check( Infinity );
    // returns false

Examples

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

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

bool = isPositiveInteger( 0.0 );
// returns false

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

bool = isPositiveInteger( 3.14 );
// returns false

bool = isPositiveInteger( NaN );
// returns false

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 © 2016-2022. The Stdlib Authors.