Skip to content

zagvar/decimal

Repository files navigation

@zagvar/decimal

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"

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors