Refunds and adjustments are negative amounts on our statements. round turns -2.5 into -2 while 2.5 becomes 3, so a charge and its refund no longer cancel out after rounding. Halves should round away from zero in both dir…
Refunds and adjustments are negative amounts on our statements. round turns -2.5 into -2 while 2.5 becomes 3, so a charge and its refund no longer cancel out after rounding. Halves should round away from zero in both directions, as they do in Ruby.
{{ -2.5 | round }}.{{ -0.5 | round }}.{{ n | round: 1 }} with n set to -1.25.-3-1-1.3-20-1.22.5 rounds to 3, and 1.25 to one decimal is 1.3.-2.49 rounds to -2 and -2.6 to -3.0.Adapted from harttle/liquidjs (MIT).
Visible test command
TZ=UTC npx --no-install jest --ci --coverage=falseThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
round-negative-halves
Changes under src/ are evaluated.