bynk.types.decimal_division_unscaled
Error / was used on Decimal operands. A quotient has no exact decimal answer, so division states its scale and rounding mode: a.div(b, 2, RoundingMode.HalfEven) (#2622).
Decimal is exact, and a quotient often has no exact decimal answer (one third), so / is not defined on it. div says what / leaves out: how many decimal places to keep and how to round. +, - and * stay exact. Write a.div(b, 2, RoundingMode.HalfEven), with the scale and mode you need.
Example
fn share(total: Decimal, ways: Decimal) -> Decimal { total / ways // ✗ no exact quotient}
fn share(total: Decimal, ways: Decimal) -> Decimal { total.div(ways, 2, RoundingMode.HalfEven) // ✓ two places, rounded}In the Book
See also
- Every code in its category, Type checking, on the diagnostic index.
bynk explain bynk.types.decimal_division_unscaledshows the same from the installed toolchain, without a network.