npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xafero/spu-integer-math

v0.0.6

Published

JavaScript Integer Math (Int8, Int16, Int32, UInt8, UInt16, UInt32, UInt64)

Downloads

2

Readme

JavaScript Integer Math

This project implements, in pure JavaScript, a way to perform integer maths with datatypes not natively available in that language.

Typescript Example


import { UInt8 } from "js-integer-math";

UInt8.add(255, 1) === 0
UInt16.add(65535, 1) === 0

Classes

Int8

export declare class Int8 {
    static add(a: i8, b: i8): i8;
    static sub(a: i8, b: i8): i8;
    static mul(a: i8, b: i8): i8;
    static div(a: i8, b: i8): i8;
    static mod(a: i8, b: i8): i8;
    static fromNumber(v: number): i8;
    static clamp(value: i8, min: i8, max: i8): i8;
    static readonly min: i8;
    static readonly max: i8;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

Int16

export declare class Int16 {
    static add(a: i16, b: i16): i16;
    static sub(a: i16, b: i16): i16;
    static mul(a: i16, b: i16): i16;
    static div(a: i16, b: i16): i16;
    static mod(a: i16, b: i16): i16;
    static fromNumber(v: number): i16;
    static clamp(value: i16, min: i16, max: i16): i16;
    static readonly min: i16;
    static readonly max: i16;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

Int32

export declare class Int32 {
    static add(a: i32, b: i32): i32;
    static sub(a: i32, b: i32): i32;
    static mul(a: i32, b: i32): i32;
    static div(a: i32, b: i32): i32;
    static mod(a: i32, b: i32): i32;
    static fromNumber(v: number): i32;
    static clamp(value: i32, min: i32, max: i32): i32;
    static readonly min: i32;
    static readonly max: i32;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

UInt8

export declare class UInt8 {
    static add(a: u8, b: u8): u8;
    static sub(a: u8, b: u8): u8;
    static mul(a: u8, b: u8): u8;
    static div(a: u8, b: u8): u8;
    static mod(a: u8, b: u8): u8;
    static fromNumber(v: number): u8;
    static clamp(value: u8, min: u8, max: u8): u8;
    static toHex(value: u8): string;
    static readonly min: u8;
    static readonly max: u8;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

UInt16

export declare class UInt16 {
    static add(a: u16, b: u16): u16;
    static sub(a: u16, b: u16): u16;
    static mul(a: u16, b: u16): u16;
    static div(a: u16, b: u16): u16;
    static mod(a: u16, b: u16): u16;
    static fromNumber(v: number): u16;
    static clamp(value: u16, min: u16, max: u16): u16;
    static toHex(value: u16): string;
    static readonly min: u16;
    static readonly max: u16;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

UInt32

export declare class UInt32 {
    static add(a: u32, b: u32): u32;
    static sub(a: u32, b: u32): u32;
    static mul(a: u32, b: u32): u32;
    static div(a: u32, b: u32): u32;
    static mod(a: u32, b: u32): u32;
    static fromNumber(v: number): u32;
    static clamp(value: u32, min: u32, max: u32): u32;
    static toHex(value: u32): string;
    static readonly min: u32;
    static readonly max: u32;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}

UInt64

export declare class UInt64 {
    readonly hi: number;
    readonly lo: number;
    constructor(lo: number | UInt64, hi?: number);
    readonly isZero: boolean;
    readonly isNonZero: boolean;
    readonly isSafeInteger: boolean;
    static add(a: number | UInt64, b: number | UInt64): UInt64;
    static sub(a: number | UInt64, b: number | UInt64): UInt64;
    static neg(b: number | UInt64): UInt64;
    static and(a: number | UInt64, b: number | UInt64): UInt64;
    static or(a: number | UInt64, b: number | UInt64): UInt64;
    static xor(a: number | UInt64, b: number | UInt64): UInt64;
    static not(a: number | UInt64): UInt64;
    static shiftLeft(value: number | UInt64, shift: number): UInt64;
    static shiftRight(value: number | UInt64, shift: number): UInt64;
    static fromNumber(value: number | UInt64): UInt64;
    static fromString(value: string, base?: number): UInt64;
    static compare(a: number | UInt64, b: number | UInt64): number;
    toHex(): string;
    toString(): string;
    toDebugString(): string;
    static toHex(a: number | UInt64): string;
    static readonly min: UInt64;
    static readonly max: UInt64;
    static readonly bitWidth: number;
    static readonly isSigned: boolean;
}