I have to mimic RPG behavior in Java. In RPG, there are 2 zoned decimal fields FLDA is length 2 with 0 decimals FLDB is length 5 with 1 decimals FLDA value = 0 FLDB 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?
Old versions of RPG had this design flaw...RPG IV corrects it when using either the
EVAL
op-code or theTRUNCNBR(*NO)
compiler option.You're going to need to write Java equivalents of RPG's
ADD
,SUB
,Z-ADD
andZ-SUB
op-codes.MOVE
would be another problematic op-code.