
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
A library for representing and working with arbitrary byte size two's complement integers, signed and unsigned.

IntN.js is a library for representing and working with arbitrary byte size two's complement integers in JavaScript,
both signed and unsigned. Its purpose is to provide a robust and convenient way to work with data types that are not
available in JavaScript natively, like 64 bit longs.
The module exports a function that creates singleton classes representing integers of the specified size in bits
(positive multiple of 8). It is compatible with CommonJS and AMD loaders and is exposed globally as dcodeIO.IntN if
neither is available.
var IntN = require("intn");
var Int8 = IntN(8),
Int16 = IntN(16),
Int24 = IntN(24),
Int32 = IntN(32),
...
Int64 = IntN(64),
...
Important: The following API documentation references the usage of the classes created by the exported function.
Instances are immutable and all methods that return another instance are chainable. Instance values are easily interchangeable using their bytes property or the fromInts and toInts methods.
Constructs a new IntN, where N is the number of bits represented by this class.
| Parameter | Type | Description |
|---|---|---|
| bytes | !Array.<number> | number | Byte values, least significant first |
| unsigned | boolean | Whether unsigned or signed, defaults to false for signed |
Number of bits represented by this IntN class.
| @type | number |
| @access | public const |
Number of bytes represented by this IntN class.
| @type | number |
| @access | public const |
Maximum unsigned value.
| @type | !IntN |
| @access | public const |
Maximum signed value.
| @type | !IntN |
| @access | public const |
Minimum signed value.
| @type | !IntN |
| @access | public const |
Negative signed one.
| @type | !IntN |
| @access | public const |
Signed one.
| @type | !IntN |
| @access | public const |
Unsigned one.
| @type | !IntN |
| @access | public const |
Unsigned zero.
| @type | !IntN |
| @access | public const |
Signed zero.
| @type | !IntN |
| @access | public const |
Adds the specified IntNs and returns the sum. Does not type check arguments.
| Parameter | Type | Description |
|---|---|---|
| a | !IntN | |
| b | !IntN | |
| @returns | !IntN |
Divides the specified dividend by the specified divisor and returns both the quotient and the remainder. Does not type check arguments.
| Parameter | Type | Description |
|---|---|---|
| dividend | !IntN | |
| divisor | !IntN | |
| @returns | !{quotient: !IntN, remainder: !IntN} |
Constructs an IntN from a 32 bit integer value.
| Parameter | Type | Description |
|---|---|---|
| value | number | Integer value |
| unsigned | boolean | Whether unsigned or not, defaults to false for signed |
| @returns | !IntN |
Reassembles an IntN from an array of 32 bit integers, least significant first.
| Parameter | Type | Description |
|---|---|---|
| ints | !Array.<number> | Array of 32 bit integers |
| unsigned | boolean | Whether unsigned or not, defaults to false for signed |
| @returns | !IntN |
Constructs an IntN from a number (double, 52 bit mantissa) value.
| Parameter | Type | Description |
|---|---|---|
| value | number | Number value |
| unsigned | boolean | Whether unsigned or not, defaults false for signed |
| @returns | !IntN |
Converts a string using the specified radix to an IntN.
| Parameter | Type | Description |
|---|---|---|
| value | string | String |
| unsigned | boolean | number | Whether unsigned or not, defaults to false for signed (omittable) |
| radix | number | Radix (2-36), defaults to 10 |
| @returns | !IntN | |
| @throws | RangeError | If radix is out of range |
| @throws | Error | If value contains illegal characters |
Tests if an object is an N bit integer, where N is this class's number of bits.
| Parameter | Type | Description |
|---|---|---|
| obj | *** | Object to test |
| @returns | boolean | true if it is an N bit integer, otherwise false |
Multiplies the specified IntNs and returns the product. Does not type check arguments.
| Parameter | Type | Description |
|---|---|---|
| a | !IntN | |
| b | !IntN | |
| @returns | !IntN |
Converts the specified value to an IntN.
| Parameter | Type | Description |
|---|---|---|
| val | !IntN | number | string | !{bytes: !Array.<number>, unsigned: boolean} | {low: number, high: number, unsigned: boolean} | Value |
| @returns | !IntN |
Represented byte values, least significant first.
| @type | !Array.<number> |
Whether unsigned or otherwise signed.
| @type | boolean |
Returns this IntN's absolute value as an unsigned IntN.
| Parameter | Type | Description |
|---|---|---|
| @returns | !IntN |
Adds the specified to this IntN and returns the sum.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Performs a bitwise and (&) operation and returns the resulting Int.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Casts this IntN of size N to the specified target IntN of size M.
| Parameter | Type | Description |
|---|---|---|
| TargetIntN | !Function | Target IntN class |
| unsigned | boolean | Whether unsigned or not, defaults to this' IntN#unsigned |
| @returns | !IntN |
Compares this IntN with the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | number | 0 if both are the same, 1 if this is greater and -1 if the specified is greater |
Divides this IntN by the specified and returns the quotient.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Tests if this IntN equals the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Tests if this IntN is greater than (>) the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Tests if this IntN is greater than or equal (>=) the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Tests if this IntN is even.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is (signed and) negative.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is odd.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is (unsigned or) positive.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is signed.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is unsigned.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is zero.
| Parameter | Type | Description |
|---|---|---|
| @returns | boolean |
Tests if this IntN is less than (<) the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Tests if this IntN is less than or equal (<=) the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Divides this IntN by the specified and returns the remainder.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Multiplies this IntN with the specified and returns the product.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Negates this IntN (*-1) and returns the result.
| Parameter | Type | Description |
|---|---|---|
| @returns | !IntN |
Performs a bitwise not (~) operation and returns the result.
| Parameter | Type | Description |
|---|---|---|
| @returns | !IntN |
Tests if this IntN does not equal the specified.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other value |
| @returns | boolean |
Performs a bitwise or (|) operation and returns the resulting Int.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Performs a shift left (<<) operation and returns the result.
| Parameter | Type | Description |
|---|---|---|
| numBits | !IntN | number | Number of bits |
| @returns | !IntN |
Performs a shift right (>>, >>>) operation and returns the result.
| Parameter | Type | Description |
|---|---|---|
| numBits | !IntN | number | Number of bits |
| logical | boolean | Whether to perform a logical (>>>) shift right, defaults to false for an arithmetic shift right (>>) |
| @returns | !IntN |
Performs an unsigned shift right (>>>) operation and returns the result.
| Parameter | Type | Description |
|---|---|---|
| numBits | !IntN | number | Number of bits |
| @returns | !IntN |
Subtracts the specified from this IntN and returns the difference.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Converts this IntN to its full binary representation. This returns N (number of bits) binary digits for
testing and debugging, followed by the character U if unsigned.
| Parameter | Type | Description |
|---|---|---|
| spaces | boolean | Whether to insert spaces between bytes, defaults to false |
| @returns | string |
Converts this IntN to a 32 bit integer.
| Parameter | Type | Description |
|---|---|---|
| unsigned | boolean | Whether unsigned or not, defaults to this' IntN#unsigned |
| @returns | number |
Disassembles this IntN into an array of 32 bit integers, least significant first.
| Parameter | Type | Description |
|---|---|---|
| @returns | !Array.<number> |
Converts this IntN to a number (double, 52 bit mantissa) value.
| Parameter | Type | Description |
|---|---|---|
| @returns | number |
Converts this IntN to signed and returns the result.
| Parameter | Type | Description |
|---|---|---|
| @returns | !IntN |
Converts this IntN to a string of the specified radix.
| Parameter | Type | Description |
|---|---|---|
| radix | !IntN | number | string | Radix (2-36), defaults to 10 |
| @returns | string | |
| @throws | RangeError | If radix is out of range |
Converts this IntN to unsigned and returns the result.
| Parameter | Type | Description |
|---|---|---|
| @returns | !IntN |
Performs a bitwise xor (^) operation and returns the result.
| Parameter | Type | Description |
|---|---|---|
| other | !IntN | number | string | Other number |
| @returns | !IntN |
Most of the methods have a couple of aliases to maintain compatibility with other libraries, to make it more convenient to use or simply to keep your code small:
If you like it rather formal:
var a = Int32.fromNumber(1),
b = Int32.fromNumber(2);
var c = a['+'](b)['/'](3);
License: Apache License, Version 2.0
FAQs
A library for representing and working with arbitrary byte size two's complement integers, signed and unsigned.
The npm package intn receives a total of 58 weekly downloads. As such, intn popularity was classified as not popular.
We found that intn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.