Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a toggle for making inexact arithmetic throw #90

Open
Drvi opened this issue Jan 5, 2024 · 0 comments
Open

Introduce a toggle for making inexact arithmetic throw #90

Drvi opened this issue Jan 5, 2024 · 0 comments

Comments

@Drvi
Copy link
Collaborator

Drvi commented Jan 5, 2024

Operations like * or \ can be lossy because they can cause the number of fractional digits to exceed the precision of the FD type, e.g.:

julia> FixedDecimal{Int,2}(1.11) * FixedDecimal{Int,2}(1.11)
FixedDecimal{Int64,2}(1.23)

while the precise answer would be FixedDecimal{Int64,4}(1.2321). During this computation, we materialize the result in full precision and then use _round_to_nearest to round to fix the FD type. It would be good to have the option to make such lossy operations throw an error by making the _round_to_nearest use RoundThrows rounding mode so that the user can be sure that their e.g. financial reports are exact. We already support RoundThrows for parsing.

This could be a global toggle in the style of ToggleableAsserts.jl .

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

No branches or pull requests

1 participant