Skip to main content

Module decimal

Module decimal 

Source
Expand description

Compile-time Decimal arithmetic helpers (#2622): the comparison and sign tests the checker needs to evaluate a decimal literal against a refinement (Positive, NonNegative, InRange). A decimal here is an optionally --prefixed coefficient string and a scale; the runtime owns the real arithmetic (bynk-emit/runtime/src/decimal.ts).

Functionsยง

canonical
The value-canonical text of a decimal: trailing fraction zeros dropped, so 1.20 and 1.2 agree (a contract is about values, not scales).
cmp
The numeric order of two decimals, ignoring how each is scaled (1.20 == 1.2).
render
A decimal in canonical text form: render("120", 2) == "1.20", render("-5", 3) == "-0.005". A scale of 0 prints no point.
sign
The sign of a coefficient: -1, 0 or 1.