int32
TypeScript icon, indicating that this package has built-in type declarations

3.0.21 • Public • Published

Int32

CI

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

You need to set up the Rust development environment: rustup

Usage

add

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

subtract

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

multiply

const n = int32.subtract(2, 6); // 12

divide

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

pow

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

shiftLeft

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

shiftRight

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

shiftRightUnsigned

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

rotateLeft

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

rotateRight

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

License

MIT

Install

npm i int32

DownloadsWeekly Downloads

20

Version

3.0.21

License

MIT

Unpacked Size

19 kB

Total Files

12

Last publish

Collaborators

  • magiclen