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 '------------------------------------------------' .
Thanks for checking the numbers and the patch.
please adjust it so:
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.
.... 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
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.