I have to mimic RPG behavior in Java. In RPG, there are 2 zoned decimal fieldsFLDA is length 2 with 0 decimalsFLDB is length 5 with 1 decimalsFLDA value = 0FLDB value = 1234.5

RPG line of code

 C Z-ADDFLDB FLDA 

FLDA value would then be 34. By default RPG does not throw an overflow exception, it truncates to fit.

How can I do this with Java BigDecimal?

1

Best Answer


Old versions of RPG had this design flaw...RPG IV corrects it when using either the EVAL op-code or the TRUNCNBR(*NO) compiler option.

You're going to need to write Java equivalents of RPG's ADD, SUB, Z-ADD and Z-SUB op-codes. MOVE would be another problematic op-code.