Strict canonical decimal-string contracts and exact arithmetic for financial and trading systems.
Use canonical base-10 strings at system boundaries instead of JavaScript floating-point numbers.
Canonical values and incoming JSON decimal literals are limited to 128 characters. Exponent notation is accepted by the literal canonicalizers only when its expanded canonical representation also fits that limit.
import { multiplyDecimals, positiveDecimalStringSchema } from "@zagvar/decimal";
const quantity = positiveDecimalStringSchema.parse("0.025");
const price = positiveDecimalStringSchema.parse("67250");
multiplyDecimals(quantity, price);
// "1681.25"