Open rawhuul opened 1 month ago
This is unfortunately related to this issue: https://github.com/paupino/rust-decimal/issues/431
The long story short is that the way that powd
works is it tries to calculate the exponent and then reduce the number back to the correct scale (rounding if necessary). Currently this uses multiplication to derive this - of which behind the scenes multiplication temporarily expands the decimal to 192 bits before shrinking back to 96 bits. Because of this, every "iteration" within powd
effectively expands and then shrinks - which of course is not effective and causes the overflow.
What should happen is that the calculation should expand to 192 bits (or more) but not scale back to 96 bits until the very last opportunity. This would help resolve situations like you're seeing above.
Overall, the fix isn't difficult, however requires some critical path refactoring to allow for more lenient multiplication steps.
Hi there, I am trying to calculate
sigmoid
of&[Decimal]
here, which fails while using Decimal but works fine after being converted tof64
, is this expected behaviour or a bug?