Skip to content

Preserve precision when comparing numbers of the same type - #1192

Merged
jknack merged 1 commit into
jknack:masterfrom
PHJ2000:fix-exact-numeric-equality
Oct 16, 2026
Merged

jknack merged 1 commit into
jknack:masterfrom
PHJ2000:fix-exact-numeric-equality

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Use the existing comparison method for same-class, comparable numbers before falling back to double. This keeps distinct Long, BigInteger, and BigDecimal values distinct in eq/neq.

Keeps the existing mixed-type fallback and floating-point equality behavior, including signed zero. Tests cover template output, big numbers, decimal scale, and those compatibility cases.

Validation: mvn -pl handlebars -am verify — 1,041 tests, no failures, 3 skipped (JDK 21). Changed Java files formatted with Spotless.

Fixes #1191.

@jknack jknack added the bug label Oct 16, 2026
@jknack jknack added this to the 4.5.6 milestone Oct 16, 2026
@jknack
jknack merged commit 85b2a33 into jknack:master Oct 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eq treats distinct large Long values as equal

2 participants