Repository navigation
fix(telemetry): write every zero Decimal as 0 - #813
Open
ParidelPooya wants to merge 1 commit into
Open
ParidelPooya wants to merge 1 commit into
ParidelPooya wants to merge 1 commit into
Conversation
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.
Contributor
Codex AI reviewNo 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 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #808 review feedback.
A zero
Decimalwith a large positive exponent has a largeadjusted()value. For example,Decimal("-0E+20").adjusted()is20. 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(or0.0forDecimal("0E+16")). The README says negative zero becomes integer0._scalar_to_json_compatiblenow returns0for every zeroDecimalbefore 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, becomes0.Decimal("-0E+20")-0.00Decimal("0E+16")0.00Decimal("-0"),Decimal("0E-200")00Testing
-0E+20,0E+16and0E-200totest_decimal_conversion, which also asserts the result type. The first two fail on main.hatch fmt --checkis clean.