Open mainframed opened 4 years ago
I noticed some weirdness as well with test 78 and replicated it with the following:
say 0 digits()
say 1 123.12345
say 2 trunc(123.12345,5)
say 3 123.12345
NUMERIC DIGITS 30
say 4 123.12345
say 5 trunc(123.12345,5)
say 6 123.12345
NUMERIC DIGITS 9
say 7 123.12345
say 8 trunc(123.12345,5)
say 9 123.12345
Output:
0 30
1 123.12345
2 123.12345
3 123.123450000000014
4 123.123450000000014
5 123.12345
6 123.123450000000008
7 123.123450000000008
8 123.12345
9 123.12345
We have found improper behavior when converting to real numbers. This error may have an effect on quite a lot of different places. Since this is most likely a problem in the compiler, we contacted Jason.
Maybe I misinterpreted the "rounding" concept of TRUNC. In my view, the rounding should occur to the last decimal digit before truncating the number. Obviously this is not the case, it looks like it is meant to be rounded to the number based on the number of DIGITS setting, and then cut off. If this is true, there is little we can do, as we don't support setting of DIGITS in the same way.
Based on IBM documentation and ooREXX truncate should round based on
DIGITS
. The default on most rexx systems is 9.To test truncate and rounding i wrote the following script:
Below will be three outputs:
Testing
On brexx I created a second script to force DIGITS to 9:
with the results: