@teakit/arith

@teakit/arith is a TypeScript arbitrary-precision decimal arithmetic package for ESM and browser environments.

Guide

Use this page as the short human entrypoint. Keep detailed API behavior in the method reference pages.

NeedRead
Install and try the packageInstallation & Usage
Find a method by taskReference Map
Compact rules for AI agentsLLMs
Skill instructions for agent runtimesSkill Instructions

Installation & Usage

npm
yarn
pnpm
bun
deno
npm install @teakit/arith
import { Arith } from "@teakit/arith";

const subtotal = Arith.from("19.99").mul(3);
const tax = subtotal.mul("0.0825");
const total = subtotal.add(tax);

total.toFixed(2); // "64.72"

Use string inputs for exact decimal values. Always create values with Arith.from(...).

Package Contract

  • Import Arith from @teakit/arith.
  • Create values with Arith.from(...); do not use new Arith(...) or call Arith(...).
  • Prefer string inputs for exact decimal values.
  • Use Arith methods instead of JavaScript arithmetic or comparison operators.
  • The package is browser-safe ESM and has no Node runtime imports.

Reference Map

TaskMethods
Constructionfrom, fromRatio, ratio
Configurationconfig, clone
Arithmeticadd, sub, mul, div
Static utilitiesallocate, sum, mean, weightedMean, median, quantile, variance, std, covariance, correlation, geometricMean, cumulativeSum, cumulativeMul, min, max, random
Rounding and digitsround, decimalPlaces, precision
Comparisoncmp, eq, ne
Formatting & conversiontoFixed, toNearest, toFormat

LLMs

AI agents should start with LLMs, then open only the relevant method reference file. Reference pages keep human usage first and AI-specific contracts near the end.