Skip to content

feat: properly handle Decimal and strings#653

Open
azelcer wants to merge 1 commit intosavoirfairelinux:masterfrom
azelcer:handle_decimals_strings
Open

feat: properly handle Decimal and strings#653
azelcer wants to merge 1 commit intosavoirfairelinux:masterfrom
azelcer:handle_decimals_strings

Conversation

@azelcer
Copy link
Copy Markdown

@azelcer azelcer commented Apr 7, 2026

Fixes #603

Changes proposed in this pull request:

  • Conversion of str and Decimal objects to cardinals honours the precision of those representations.
  • Conversion of str and Decimal objects to cardinals do not introduce floating-point representation errors.

Status

  • READY
  • HOLD
  • WIP (Work-In-Progress)

How to verify this change

  • Library should work as before for float objects
  • Library should handle Decimal and str taking in account the exact values represented
  • No floating-point rounding errors should be introduced when dealing with instances of those types

Additional notes

Some values are not exactly representable as per IEEE 754 standard (the issue #603 that initiated this PR deals with number 98_746_251_323_029.99). Nevertheless, those values have an exact representation as Decimal or str objects. Currently the library converts these types to floats before processing, introducing floating-point inaccuracies. I have added a separate path for dealing with these number representation formats.

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.

Incorrect approximation for decimal numbers

1 participant