So, whilst pursuing the COBOL 2014 ISO standard (as one does) I had a thought. The standard allows for one of a number of "rounding modes" to be specified. One of these is the mode called "PROHIBITED". This means that if "the arithmetic value cannot be represented exactly in the resultant identifier, the EC-SIZE-TRUNCATION exception condition is set to exist, the size error condition exists, and the content of the resultant identifier is unchanged."
For example, given num-val as above, if you specified the statement `COMPUTE num-val ROUNDED MODE IS PROHIBITED = 9.1`, I believe that this would trigger the EC-SIZE-TRUNCATION exception, and any ON SIZE ERROR clause, if present, would be invoked. So in turn, if we had the statement `COMPUTE num-val ROUNDED MODE IS PROHIBITED = FUNCTION NUMVAL(input-area)`, if (in this case) there was any non-zero digit following the decimal point, it should also trigger the same exception.
This seems to me a fairly elegant solution to the issue. And of course adding ROUNDED MODE to Enterprise COBOL could be useful beyond this particular use case.
I do have a concern, however. It appears that currently even if no ROUNDED phrase is specified, if the "sending item" is one of the NUMVAL functions the result is still being rounded (up). I don't know if this has anything to do with the note in the Enterprise COBOL reference for the ROUNDED phrase that states "In a floating-point arithmetic operation, the ROUNDED phrase has no effect; the result of a floating-point operation is always rounded", but it seems to me that this should not occur if the "receiving item" is not a floating point data item.
Anyway, I would be glad to open an RFE to support the additional rounding modes if the IBM COBOL team thinks its something they might realistically implement.
Thanks! Frank
fswarbrick