32-bit integer can store values from −2^31 to 2^31 − 1.

Usage no npm install needed!

<script type="module">
  import extraIntegerMin from 'https://cdn.skypack.dev/extra-integer.min';


32-bit integer can store values from −2^31 to 2^31 − 1.
:package: NPM, :smiley_cat: GitHub, :running: RunKit, :vhs: Asciinema, :moon: Minified, :scroll: Files, :newspaper: JSDoc, :blue_book: Wiki.

This package includes bit twiddling hacks, for integers, by Sean Eron Anderson and many others.

Methods as separate packages:

Stability: Experimental

This is browserified, minified version of extra-integer.
It is exported as global variable integer.
CDN: unpkg, jsDelivr.

const integer = require("extra-integer");
// import * as integer from "extra-integer";
// import * as integer from "https://unpkg.com/extra-integer@2.0.30/index.mjs"; (deno)

// false

// 4

// 64


Method Action
is Checks if value is int32.
abs Gets absolute value.
log2 Finds log-base-2.
pow2 Finds power-of-2.
isPow2 Checks if value is a power-of-2.
nextPow2 Finds next power-of-2.
prevPow2 Finds previous power-of-2.
signEqual Checks if two values have equal sign.
MIN_VALUE Minimum int32 value.