JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q40599F

Fixed-point numbers for the web

Package Exports

  • @hazae41/fixed

Readme

Fixed

Fixed-point numbers for the web

npm install @hazae41/fixed

📦 NPM

Features

Current features

  • 100% TypeScript and ESM
  • No external dependencies

Usage

const x0 = new Fixed(123n, 0)   // [123n;0]
const x18 = x0.move(18)         // [123000000000000000000n;18]

const y18 = new Fixed(1n, 18)   // [000000000000000000001n;18]
const z18 = x18.add(y18)        // [123000000000000000001n;18]

const str = z18.toString()      // "123.000000000000000001"
const num = Number(str)         // 123
const int = BigInt(num)         // 123n