Unless you know the number of decimals before hand, there is no way to do it correctly.
If there was a field that had the number of decimals need you could set up a a bunch if tests.
when dec_needed = 2 then a move to a work_2dec.
when dec_needed = 3 then a move to a work_3dec.
when dec_needed = 4 then a move to a work_4dec.
At the end of test, add to you final workfield.
But unless you know the decimals this will not work…