Menu ▾ ▴

#478 float-decimal intermediate rounding and exceptions are not always correct

GC 3.0
closed
5 - default
2017-12-23
2017-12-16
No

This is a follow-up to [bugs:#470] which showed that computations with ON SIZE ERROR are handled different than computations without - but this shouldn't be the case.

In general this is what should be done in this case:

  • use an intermediate decimal128 item for each part

  • if the result of an intermediate item would be farther from zero than is allowed: -9 999 999 999 999 999 999 999 999 999 999 999E+6144 and +9 999 999 999 999 999 999 999 999 999 999 999E+6144- the EC-SIZE-OVERFLOW exception condition is set to exist and the content of the resultant identifier is unchanged.

  • if the result of an intermediate item would be nearer to zero than is allowed: 1.0E-6176 and +1.0E-6175 - the INTERMEDIATE ROUNDING clause active should be checked:

    • PROHIBITED - EC-SIZE-TRUNCATION is set (further results undefined, I'd say: do rounding and further calculation)
    • all others or none specified - the intermediate value is set to the nearest possible zero value
  • if the result of a receiving item would be nearer to zero than is allowed: 1.0E-6176 and +1.0E-6175
    --> ideally depending on a compiler configuration flag:
    --> configuration value1 (defined in COBOL 2014): the EC-SIZE-UNDERFLOW exception condition is set to exist and the content of the resultant identifier is unchanged
    --> configuration value2 (defined in COBOL 2002 which doesn't has EC-SIZE-UNDERFLOW): the receiving item is set to the nearest possible zero value

  • if the receiving item is a FLOAT-DECIMAL-16 item the following additional rules exist

    • if the value is farther from zero than is allowed: -9.999 999 999 999 99E+384 and +9.9999 999 999 999 999E+384- the EC-SIZE-OVERFLOW exception condition is set to exist and the content of the resultant identifier is unchanged.
    • if the value is nearer to zero than is allowed: 1.0E-398 and +1.0E-398
      --> ideally depending on a compiler configuration flag:
      --> configuration value1 (defined in COBOL 2014): the EC-SIZE-UNDERFLOW exception condition is set to exist and the content of the resultant identifier is unchanged
      --> configuration value2 (defined in COBOL 2002 which doesn't has EC-SIZE-UNDERFLOW): the receiving item is set to the nearest possible zero value

If any of the mentioned exceptions is set the statements in the ON SIZE ERROR phrase should be executed.

Related

Bugs: #470

Discussion

  • Simon Sobisch

    Simon Sobisch - 2017-12-20
    • Group: GC 3.0 --> GC 3.x
     
  • Simon Sobisch

    Simon Sobisch - 2017-12-23
    • status: accepted --> closed
    • Group: GC 3.x --> GC 3.0
     
  • Simon Sobisch

    Simon Sobisch - 2017-12-23

    Considered to be fine in re-branch after Ron's changes, merged to trunk with [r2324]. We should add test cases for intermediate rounding options, but this can be done after the rc-1 (ideally before the final release).

     

Log in to post a comment.