Menu

#70 Patch Proposition ti Fix #1206 ticket

GC 3.x
open
nobody
None
5 - default
2026-03-18
2026-03-15
No

hi Simon

here is a first past proposed .
To fix the limits i have simply test when gnucobol does not produce usable number in float long format as it is the largest limits we have
Here is the program i used

       IDENTIFICATION DIVISION.
       PROGRAM-ID . stuff .
      *>
       ENVIRONMENT DIVISION.
       DATA DIVISION .
       WORKING-STORAGE  SECTION.

       01 B               FLOAT-LONG      .

      *>
       PROCEDURE DIVISION .
      *>------------------
      *>

      *    KO means that the result in floatingg point is not meaningful
      *    ie the floating point result is 0
      *
      *

      *====================== EXP   ============================

      *    OK
           display 'EXP 709' .
           MOVE FUNCTION EXP(709) TO  B .
           display b.
           display '------------------------------------------------' .
      *    OK
           display 'EXP 710' .
           MOVE FUNCTION EXP(710) TO  B .
           display b.
           display '------------------------------------------------' .
      *    OK
           display 'EXP -744' .
           MOVE FUNCTION EXP(-744) TO  B .
           display b.
           display '------------------------------------------------' .
      *    OK
           display 'EXP -745' .
           MOVE FUNCTION EXP(-745) TO  B .
           display b.
           display '------------------------------------------------' .
      *====================== EXP10 ============================
      *    OK
           display 'EXP10 308' .
           MOVE FUNCTION EXP10(308) TO  B .
           display b.
           display '------------------------------------------------' .
      *    KO
           display 'EXP10 309' .
           MOVE FUNCTION EXP10(309) TO  B .
           display b.
           display '------------------------------------------------' .



      *    OK
           display 'EXP10 -323' .
           MOVE FUNCTION EXP10(-323) TO  B .
           display b.
           display '------------------------------------------------' .



      *    KO
           display 'EXP10 -324' .
           MOVE FUNCTION EXP10(-324) TO  B .
           display b.
           display '------------------------------------------------' .

      *====================== FACTORIAL ============================

      *    OK
           display 'FACT 170' .
           MOVE FUNCTION FACTORIAL(170) TO  B .
           display b.
           display '------------------------------------------------' .
      *    OK
           display 'FACT 171' .
           MOVE FUNCTION FACTORIAL(171) TO  B .
           display b.
           display '------------------------------------------------' .
1 Attachments

Discussion

  • Simon Sobisch

    Simon Sobisch - 2026-03-15

    Thanks for checking the numbers and the patch.
    please adjust it so:

    • exception EC-ARGUMENT-FUNCTION is raised
    • no NaN is set
    • for "too big" set COB_DECIMAL_INF
    • for "too small" numbers set the srcval/mpf to the min you've found working "+/- 1"

    Can you add an entry for libcob/Changelog and tests/testsuite.src/run_misc.at with your test code into your patch as well? Then we can easily see how portable the given tests are.

     
  • Simon Sobisch

    Simon Sobisch - 2026-03-15

    .... Side note: we do need to check COB_DECIMAL_INF in all places where we currently check NaN and likely return INF in most places (and/or raise an exception or return 0); you may add that in the same patch

     
  • Denis HUGONNARD-ROCHE

    Simon
    Here's the fix for exp, exp 10, and factorial. I've also included other tests for these functions, unrelated to the fix, to improve code coverage.

     

Log in to post a comment.

MongoDB Logo MongoDB