Skip to content

Fold positive Decimal exponents into the mantissa. - #592

Open
agrawal-priyank wants to merge 1 commit into
duckdb:mainfrom
agrawal-priyank:fix/decimal-positive-exponent
Open

Fold positive Decimal exponents into the mantissa.#592
agrawal-priyank wants to merge 1 commit into
duckdb:mainfrom
agrawal-priyank:fix/decimal-positive-exponent

Conversation

@agrawal-priyank

Copy link
Copy Markdown

Summary

  • In PyDecimal, treat a positive exponent as trailing zeros on the mantissa and emit DECIMAL(width, 0), instead of using the exponent as a DECIMAL scale. That scale cancelled the 10^n multiply and stored only the mantissa (Decimal('1E+2')1; 1E+20 could also overflow int64 and flip the sign).
  • Leave fractional Decimals and Arrow/SQL casts unchanged.
  • Add round-trip and insert regression tests from the issue, and update the sqlite/pandas cases that encoded the old 1E51 behavior.

Fixes #566

Test plan

  • uv run pytest tests/fast/types/test_decimal.py -v
  • uv run pytest tests/fast/sqlite/test_types.py -v
  • uv run pytest tests/fast/pandas/test_df_object_resolution.py -v
  • uv run pytest tests/fast/test_value.py -v
  • CI on this PR

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 with a positive exponent is silently stored as its mantissa (Decimal('1E+2') → 1)

1 participant