Skip to content

Fix Decimal.normalize() causing silent precision loss#44

Merged
dannywillems merged 4 commits intomainfrom
fix-decimal-normalize
Feb 8, 2026
Merged

Fix Decimal.normalize() causing silent precision loss#44
dannywillems merged 4 commits intomainfrom
fix-decimal-normalize

Conversation

@dannywillems
Copy link
Contributor

Summary

  • Remove .normalize() from round_decimal() which was stripping trailing
    zeros (e.g. Decimal("1.000000") becoming Decimal("1"))
  • This ensures serialize(deserialize(x)) == x for quantized values

Closes #28

Decimal.normalize() strips trailing zeros, causing
serialize(deserialize(x)) != x for values like "1.000000".
Removing it preserves the quantized precision.

Closes #28
Ensures serialize(deserialize(x)) preserves values, guarding against
re-introduction of normalize() which strips trailing zeros.
@dannywillems dannywillems force-pushed the fix-decimal-normalize branch from f51f612 to 23b3cc2 Compare February 8, 2026 01:47
@dannywillems dannywillems merged commit 79979b5 into main Feb 8, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decimal.normalize() causes silent precision loss

1 participant