{"id":19908713,"url":"https://github.com/princess-rosella/spu-integer-math","last_synced_at":"2026-05-14T19:33:48.232Z","repository":{"id":57283238,"uuid":"147877163","full_name":"princess-rosella/spu-integer-math","owner":"princess-rosella","description":"JavaScript Integer Math","archived":false,"fork":false,"pushed_at":"2019-12-14T01:44:43.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T00:07:53.329Z","etag":null,"topics":["integer-arithmetic","javascript","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/princess-rosella.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-07T21:36:57.000Z","updated_at":"2024-06-16T19:04:59.000Z","dependencies_parsed_at":"2022-09-17T13:53:47.376Z","dependency_job_id":null,"html_url":"https://github.com/princess-rosella/spu-integer-math","commit_stats":null,"previous_names":["princess-rosella/js-integer-math"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princess-rosella%2Fspu-integer-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princess-rosella%2Fspu-integer-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princess-rosella%2Fspu-integer-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/princess-rosella%2Fspu-integer-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/princess-rosella","download_url":"https://codeload.github.com/princess-rosella/spu-integer-math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241335595,"owners_count":19946086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integer-arithmetic","javascript","typescript"],"created_at":"2024-11-12T21:13:03.636Z","updated_at":"2026-05-14T19:33:48.156Z","avatar_url":"https://github.com/princess-rosella.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript Integer Math\n\nThis project implements, in pure JavaScript, a way to perform integer maths with datatypes not natively available in that language.\n\n## Typescript Example\n\n```typescript\n\nimport { UInt8 } from \"js-integer-math\";\n\nUInt8.add(255, 1) === 0\nUInt16.add(65535, 1) === 0\n\n```\n\n## Classes\n\n### Int8\n\n```typescript\nexport declare class Int8 {\n    static add(a: i8, b: i8): i8;\n    static sub(a: i8, b: i8): i8;\n    static mul(a: i8, b: i8): i8;\n    static div(a: i8, b: i8): i8;\n    static mod(a: i8, b: i8): i8;\n    static fromNumber(v: number): i8;\n    static clamp(value: i8, min: i8, max: i8): i8;\n    static readonly min: i8;\n    static readonly max: i8;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### Int16\n\n```typescript\nexport declare class Int16 {\n    static add(a: i16, b: i16): i16;\n    static sub(a: i16, b: i16): i16;\n    static mul(a: i16, b: i16): i16;\n    static div(a: i16, b: i16): i16;\n    static mod(a: i16, b: i16): i16;\n    static fromNumber(v: number): i16;\n    static clamp(value: i16, min: i16, max: i16): i16;\n    static readonly min: i16;\n    static readonly max: i16;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### Int32\n\n```typescript\nexport declare class Int32 {\n    static add(a: i32, b: i32): i32;\n    static sub(a: i32, b: i32): i32;\n    static mul(a: i32, b: i32): i32;\n    static div(a: i32, b: i32): i32;\n    static mod(a: i32, b: i32): i32;\n    static fromNumber(v: number): i32;\n    static clamp(value: i32, min: i32, max: i32): i32;\n    static readonly min: i32;\n    static readonly max: i32;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### UInt8\n\n```typescript\nexport declare class UInt8 {\n    static add(a: u8, b: u8): u8;\n    static sub(a: u8, b: u8): u8;\n    static mul(a: u8, b: u8): u8;\n    static div(a: u8, b: u8): u8;\n    static mod(a: u8, b: u8): u8;\n    static fromNumber(v: number): u8;\n    static clamp(value: u8, min: u8, max: u8): u8;\n    static toHex(value: u8): string;\n    static readonly min: u8;\n    static readonly max: u8;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### UInt16\n\n```typescript\nexport declare class UInt16 {\n    static add(a: u16, b: u16): u16;\n    static sub(a: u16, b: u16): u16;\n    static mul(a: u16, b: u16): u16;\n    static div(a: u16, b: u16): u16;\n    static mod(a: u16, b: u16): u16;\n    static fromNumber(v: number): u16;\n    static clamp(value: u16, min: u16, max: u16): u16;\n    static toHex(value: u16): string;\n    static readonly min: u16;\n    static readonly max: u16;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### UInt32\n\n```typescript\nexport declare class UInt32 {\n    static add(a: u32, b: u32): u32;\n    static sub(a: u32, b: u32): u32;\n    static mul(a: u32, b: u32): u32;\n    static div(a: u32, b: u32): u32;\n    static mod(a: u32, b: u32): u32;\n    static fromNumber(v: number): u32;\n    static clamp(value: u32, min: u32, max: u32): u32;\n    static toHex(value: u32): string;\n    static readonly min: u32;\n    static readonly max: u32;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```\n\n### UInt64\n\n```typescript\nexport declare class UInt64 {\n    readonly hi: number;\n    readonly lo: number;\n    constructor(lo: number | UInt64, hi?: number);\n    readonly isZero: boolean;\n    readonly isNonZero: boolean;\n    readonly isSafeInteger: boolean;\n    static add(a: number | UInt64, b: number | UInt64): UInt64;\n    static sub(a: number | UInt64, b: number | UInt64): UInt64;\n    static neg(b: number | UInt64): UInt64;\n    static and(a: number | UInt64, b: number | UInt64): UInt64;\n    static or(a: number | UInt64, b: number | UInt64): UInt64;\n    static xor(a: number | UInt64, b: number | UInt64): UInt64;\n    static not(a: number | UInt64): UInt64;\n    static shiftLeft(value: number | UInt64, shift: number): UInt64;\n    static shiftRight(value: number | UInt64, shift: number): UInt64;\n    static fromNumber(value: number | UInt64): UInt64;\n    static fromString(value: string, base?: number): UInt64;\n    static compare(a: number | UInt64, b: number | UInt64): number;\n    toHex(): string;\n    toString(): string;\n    toDebugString(): string;\n    static toHex(a: number | UInt64): string;\n    static readonly min: UInt64;\n    static readonly max: UInt64;\n    static readonly bitWidth: number;\n    static readonly isSigned: boolean;\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincess-rosella%2Fspu-integer-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprincess-rosella%2Fspu-integer-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprincess-rosella%2Fspu-integer-math/lists"}