Skip to content

Stop the sum filter rounding integer totals #18

Closed

Description

@qoke

The sum filter uses floating-point accumulation for integer inputs, which can silently change the total.

{{ [9007199254740993, 2] | sum }}

Python Jinja2 returns:

9007199254740995

The affected Go implementation returns:

9007199254740994

Every input and the correct total fit within the supported integer range, so this isn’t an overflow case. We’re losing precision by taking integer arithmetic through floating point.

I’m preparing a PR to use the engine’s existing value-addition operation for accumulation. That keeps integer inputs in integer arithmetic and allows floating-point promotion when required. I’ll attach it here with a regression test checking the exact rendered result. This change won’t add arbitrary-precision integers or address integer overflow beyond the engine’s existing behaviour.

Activity

  1. ardan-bkennedy commented on Oct 26, 2026

    @ardan-bkennedy
    Contributor

    Resolved in #34 and published in v1.11.0, with corresponding regression tests covering the reported problem. Thank you, @qoke, for the report and suggested solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions