FA-61964 / Currency rounding and FX conversion / Member archive
A converted credit that rounds to zero is emitted as minus zero · case 04
A one-cent credit converted at 0.3 shows as '-0.00' on the invoice.
Case contract
solve(lines, rate, exp): lines are source-currency decimal strings (credits negative), rate a decimal string, exp the target exponent. The converted total is round_half_even(sum(lines)*rate) at exp. Each line is converted and rounded half-even individually; the difference between the converted total and the sum of converted lines is posted in full to the line with the largest absolute source amount (earliest on ties). Return the converted lines as plain strings; zero lines are unsigned. An empty invoice returns [].
Why this case matters
Currency amounts must be rounded at the right stage and in the right unit, or ledgers, quotes and settlements drift by minor units.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression signed-zero-line 1 | ["30.00", "-0.00"] | ["30.00", "0.00"] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗