Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@stdlib/math-base-assert-is-nonnegative-integer
Advanced tools
Test if a finite double-precision floating-point number is a nonnegative integer.
Test if a finite double-precision floating-point number is a nonnegative integer.
npm install @stdlib/math-base-assert-is-nonnegative-integer
var isNonNegativeInteger = require( '@stdlib/math-base-assert-is-nonnegative-integer' );
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
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
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
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.
See LICENSE.
Copyright © 2016-2021. The Stdlib Authors.
0.0.2 (2021-06-15)
No changes reported for this release.
</section> <!-- /.release --> <section class="release" id="v0.0.1">FAQs
Test if a finite double-precision floating-point number is a nonnegative integer.
The npm package @stdlib/math-base-assert-is-nonnegative-integer receives a total of 32,413 weekly downloads. As such, @stdlib/math-base-assert-is-nonnegative-integer popularity was classified as popular.
We found that @stdlib/math-base-assert-is-nonnegative-integer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.