# money cheatsheet
Every export of @deckyard/money. Guides are listed in the introduction .
jennifer import "@deckyard/money/" as money;
Every failure is Error{kind: "money"}. A code is an ISO 4217 code such as "EUR"; a mode is one of MODES. Factors, rates and ratios are decimal strings such as "1.19".
# Constants
Constant Value Meaning ERROR_KIND"money"the kind of every error the deck throws MODES["half-even", "half-up", "half-down", "up", "down", "ceiling", "floor"]the rounding modes MAX_TEXT50the longest amount, factor, rate or ratio string MAX_PARTS100000the most parts allocate and allocateTo make
# Types
# Money
Field Meaning amount as intminor units: 1234 for 12.34 EUR currency as stringthe ISO 4217 code
# Making and reading
Function Returns Does money.fromMinor(amount, code)Moneyan amount of minor units money.zero(code)Moneyzero money.parse(text, code)Moneyread "12.34"; extra places only if zeros money.format(m)string"12.34", "1200" for JPYmoney.fromDecimal(d, code, mode)Moneya decimal in major units, rounded money.toDecimal(m)decimal.Decimalthe amount in major units
# Currencies
Function Returns Does money.isCurrency(code)boolwhether the code is in the table money.digits(code)intthe minor units: 0, 2, 3 or 4 money.currencies()list of stringevery code, sorted money.published()stringthe date of the ISO 4217 list used
# Arithmetic
Function Returns Does money.add(a, b)Moneya + bmoney.subtract(a, b)Moneya - bmoney.sum(ms, code)Moneythe total of a list; zero when empty money.negate(m)Money-mmoney.absolute(m)Money|m|money.multiply(m, factor, mode)Moneym * factor, roundedmoney.divide(m, divisor, mode)Moneym / divisor, roundedmoney.allocate(m, ratios)list of Moneysplit by ratios; the parts sum to m money.allocateTo(m, n)list of Moneysplit into n equal parts money.exchange(m, code, rate, mode)Moneyinto another currency at rate, rounded
# Comparing
Function Returns Does money.compare(a, b)int-1, 0 or 1 money.lessThan(a, b)boola < bmoney.greaterThan(a, b)boola > bmoney.isZero(m)boolm == 0money.isNegative(m)boolm < 0money.isPositive(m)boolm > 0
# The currencies module
import "@deckyard/money/currencies.j" as currencies; reads the table itself. It is generated; see Currencies .
Constant Value Meaning currencies.PUBLISHED"2026-09-17"the date of the ISO 4217 list currencies.DIGITS{"AED": 2, ...}each code's minor units