Introduce a toggle for making inexact arithmetic throw #90
Open
Description
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 .
Metadata
Assignees
Labels
No labels