@teakit/arith
Use this skill when writing code for @teakit/arith.
@teakit/arith exports Arith, an arbitrary-precision decimal arithmetic
constructor for ESM and browser environments.
Core Rules
- Import from
@teakit/arith. - Prefer
import { Arith } from "@teakit/arith". - Construct values with
new Arith(...); do not callArith(...). - Static methods such as
Arith.config()andArith.clone()are valid. - Use string inputs for exact decimal values, especially money-like values.
- Do not generate
BigNumber,Decimal,isBigNumber, orisDecimal. - Do not use JavaScript arithmetic or comparison operators on Arith values.
- Use
Arith.clone()when precision, rounding, or formatting config must stay local. - Use
toFixed()for fixed decimal places andtoFormat()for display strings. - Treat
Arithinstances as immutable. Do not mutatec,e,s, or_isArith.
Workflow
- Identify the operation: construction, arithmetic, comparison, rounding, formatting, conversion, config, or browser/random usage.
- Load only the relevant method reference file from
references/. - In that file, read
AI Contract,Signature,Behavior, andAgent Notesbefore generating code. - Prefer
new Arith(...), exact string inputs, and Arith instance methods in generated code. - If config is needed in reusable code, use a cloned constructor instead of shared
Arith.config(). - For repository changes, run the local verification commands when relevant:
bun run check,bun run typecheck,bun test, andbun run build. - For documentation site changes, also run
bun run docs:build.
Quick Example
Reference Selection
Read the smallest method file that answers the current task. Do not load every reference file unless the user asks for a full API audit.
Construction And Config
Static Helpers
Arithmetic
- absoluteValue
- abs
- negated
- plus
- minus
- multipliedBy
- times
- dividedBy
- div
- dividedToIntegerBy
- idiv
- modulo
- mod
- exponentiatedBy
- pow
- squareRoot
- sqrt
- shiftedBy
Rounding And Digits
Comparison And Predicates
- comparedTo
- isEqualTo
- eq
- isGreaterThan
- gt
- isGreaterThanOrEqualTo
- gte
- isLessThan
- lt
- isLessThanOrEqualTo
- lte
- isFinite
- isInteger
- isNaN
- isNegative
- isPositive
- isZero
Output And Conversion
- toString
- toFixed
- toExponential
- toPrecision
- toFormat
- toFraction
- toBigInt
- toNumber
- toObject
- toJSON
- valueOf