Skip to content

fix(telemetry): write every zero Decimal as 0 - #813

Open
ParidelPooya wants to merge 1 commit into
mainfrom
fix/telemetry-decimal-zero
Open

ParidelPooya wants to merge 1 commit into
mainfrom
fix/telemetry-decimal-zero

Conversation

@ParidelPooya

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #808 review feedback.

A zero Decimal with a large positive exponent has a large adjusted() value. For example, Decimal("-0E+20").adjusted() is 20. The integer check skipped it, and the range check skipped it because zero is falsy. The value was then written as the float -0.0 (or 0.0 for Decimal("0E+16")). The README says negative zero becomes integer 0.

_scalar_to_json_compatible now returns 0 for every zero Decimal before any exponent check. The range check no longer needs its zero guard. The README and docstring now say every zero, of any sign or exponent, becomes 0.

Input Before After
Decimal("-0E+20") -0.0 0
Decimal("0E+16") 0.0 0
Decimal("-0"), Decimal("0E-200") 0 0

Testing

  • Added -0E+20, 0E+16 and 0E-200 to test_decimal_conversion, which also asserts the result type. The first two fail on main.
  • Exporter test suite passes locally. hatch fmt --check is clean.

A zero Decimal with a large exponent, such as Decimal("-0E+20"), has a large adjusted() value, so the integer check skipped it and it was written as the float -0.0 or 0.0. The README says every zero becomes integer 0. Zero is now checked first.
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime October 23, 2026 04:51 — with GitHub Actions Active
@ParidelPooya
ParidelPooya deployed to ai-pr-review-runtime October 23, 2026 04:52 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Codex AI review

No actionable findings. Added regression cases cover zero signs and exponents and assert integer output. Runtime validation remains unverified because tests were not executed, as requested.

Reviewed commit 9fbb241958e08f9a69e27387b4640ebd5140a93b. Workflow run

@yaythomas yaythomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

This branch was successfully deployed

1 active deployment
ai-pr-review-runtime — 9fbb2419 Deployed Oct 23, 2026 by ParidelPooya via ai-pr-review / Codex review / Generate Codex review #2168
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.

2 participants