Hsieh,
Jeff and I looked at this some more and we now know what is going on.
In the example, the target field of the assignment has no decimals, but the rounding integer is set to -1 (which means round at the first decimal place).
In this specific case,
- VAGen is rounding based on the left hand side of the expression.
- EGL is doing the rounding first based on VALOR1 and then doing the assignment to Valor2.
The truncateExtraDecimals is controlling the last part of this which is the assignement to Valor2 of 74.5 (the rounded value at one decimal place). With truncateExtraDecimals=YEs, the result is 74, with =NO, it is 75.
However, since truncateExtraDecimals is a build descriptor which affects all the program/programs...and in general we say "=YES" maintains VAGen behavior, I don't think you want to set this to "NO".
So, there are two other solutions for this case.
Change the assignment statement to use mathlib.assign, so something like this:
mathlib.assign(mathLib.round(VALOR1, WS_DECIMAL), valor2);
Or change the rounding value to match the rounding to the digit you really want to receive the rounding (i.e. the first digit to the left of the decimal point). This means set the rounding value to 0.
VALOR1 decimal(13,6) ; // item
VALOR2 decimal(13,1) ; // item
WS_DECIMAL int ; // item
VALOR1 = 74.514915;
WS_DECIMAL = 0;
VALOR2 = mathLib.round(VALOR1, WS_DECIMAL);
Both ways get the same results in the debugger and in generated COBOL.
Mark
markevans