decrements this value
creates a dense representation of this value
increments this value
multiplies this value by the given factor
the factor to multiply by
formats this discrete value as a decimal string
creates a new scale based on the given currency, unit and ratio
const euroCent = Discrete.scale("EUR", "cent", Rational.of(100, 1));
const euro = Discrete.scale("EUR", "euro", Rational.of(1, 1));
const usdCent = Discrete.scale("USD", "cent", Rational.nat(100));
const xauTroyOunce = Discrete.scale("XAU", "troy-ounce", Rational.nat(1));
const xauGram = Discrete.scale("XAU", "gram", Rational.fromDecimal("31.103477"));
the currency name
the unit name
the ratio between the unit and the currency main unit
Generated using TypeDoc
A discrete monetary value.
A discrete value is always an integer multiple of a currency unit.
Discrete instances are immutable.
A discrete value is based on a scale. The scale is the ratio between the chosen unit and the main currency unit.
const euroCent = Discrete.scale("EUR", "cent", Rational.of(100, 1)); const euro = Discrete.scale("EUR", "euro", Rational.of(1, 1)); Discrete.of(42, euroCent).add(Discrete.of(23, euro)); // type error, euro is not assignable to cent