# int32

> Use Rust to compute 32-bit signed integers and wrap around at the boundary.

Latest version **6.0.0** (published 2026-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install int32
pnpm add int32
yarn add int32
bun add int32
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2026-09-15 |
| First published | 2017-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 1 |
| Unpacked size | 16.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 2 |
| Author | Magic Len |
| Maintainers | magiclen |
| Keywords | int32, nodejs, overflow, underflow |

## Links

- npm: https://www.npmjs.com/package/int32
- Repository: https://github.com/magiclen/node-int32
- Homepage: https://magiclen.org/node-js-int32/
- Issues: https://github.com/magiclen/node-int32/issues
- npm.io page: https://npm.io/package/int32

## Dependencies (1)

- [@napi-rs/cli](https://npm.io/package/@napi-rs/cli.md) ^3.9.1

## Recent versions

- 6.0.0 (latest) — 2026-09-15
- 5.0.0 — 2024-10-22
- 4.0.7 — 2023-10-04
- 4.0.6 — 2023-05-04
- 4.0.5 — 2023-04-26
- 4.0.4 — 2023-04-18
- 4.0.3 — 2023-04-18
- 4.0.2 — 2023-04-18
- 4.0.1 — 2023-04-18
- 4.0.0 — 2023-04-14
- 3.0.21 — 2022-05-12
- 3.0.20 — 2022-05-12
- 3.0.19 — 2021-07-26
- 3.0.18 — 2021-06-10
- 3.0.17 — 2021-06-03
- … 28 more at https://npm.io/package/int32/versions

## README

Int32
=================================

[![CI](https://github.com/magiclen/node-int32/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/node-int32/actions/workflows/ci.yml)

Use Rust to compute 32-bit signed integers and wrap around at the boundary.

## Requirements and Installation

Node.js 24 or later and Rust 1.88.0 or later are required. Install Rust with [rustup](https://rustup.rs/) and the native linker for your platform (a C compiler on Linux/macOS or the MSVC build tools on Windows).

```sh
npm install int32
```

Installation compiles the native module from source using the included `Cargo.lock`. Package managers that block dependency build scripts must allow the `int32` install script; for pnpm, approve `int32` with `pnpm approve-builds` and rebuild it with `pnpm rebuild int32`. If npm requires script approval, use `npm install-scripts approve int32` followed by `npm rebuild int32`.

## Usage

#### add

```typescript
import { add } from "int32";

const n = add(1, 2); // 3
```

#### subtract

```typescript
import { subtract } from "int32";

const n = subtract(1, 2); // -1
```

#### multiply

```typescript
import { multiply } from "int32";

const n = multiply(2, 6); // 12
```

#### divide

```typescript
import { divide } from "int32";

const n = divide(6, 4); // 1
```

#### pow

```typescript
import { pow } from "int32";

const n = pow(2, 3); // 8
```

#### shiftLeft

```typescript
import { shiftLeft } from "int32";

const n = shiftLeft(5, 2); // 20
```

#### shiftRight

```typescript
import { shiftRight } from "int32";

const n1 = shiftRight(5, 2); // 1
const n2 = shiftRight(6, 1); // 3
const n3 = shiftRight(-5, 1); // -3
```

#### shiftRightUnsigned

```typescript
import { shiftRightUnsigned } from "int32";

const n = shiftRightUnsigned(-5, 1); // 2147483645
```

#### rotateLeft

```typescript
import { rotateLeft } from "int32";

const n = rotateLeft(0b10000000000000000000000100000000, 1); // 0b00000000000000000000001000000001
```

#### rotateRight

```typescript
import { rotateRight } from "int32";

const n = rotateRight(0b00000000000000000000000100000001, 8); // 0b00000001000000000000000000000001
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/int32 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
