Menu

#989 Power

GC 3.x
open
nobody
Power (2)
5 - default
2024-10-23
2024-09-20
No

Hi Simon
i have found another bug on the cob_decimal_pow function :
When a exponent is an integer and does not fit to ulong or slong then we execute the compute with Taylor series function.
But in this case , the sign of the result is not properly computed as we have to check if the exponent is even or odd in order to get the correct result sign

For example :
1.0000000000000000000000000000000000001 ** -9223372036854776134
should give 0.9999999999999999990776627963145223870
instead the result is -0.9999999999999999990776627963145223870

   Denis

Discussion

  • Simon Sobisch

    Simon Sobisch - 2024-09-20
     
  • Simon Sobisch

    Simon Sobisch - 2024-09-20

    sounds like you can come up with a minimal COBOL program for the testsuite and a fix for libcob - please give it a go

     
  • Denis HUGONNARD-ROCHE

    yes i'm working on it :-)

     
    ❤️
    1
  • Denis HUGONNARD-ROCHE

    Hi Simon
    Here is an example.
    I have a hudge patch that include bug fixes #924, #925, #989 and a full testing suite for power compute.
    I will send it as a pull request to the ocaml repository .

    Denis

       IDENTIFICATION DIVISION.
       PROGRAM-ID . tstpow  .
      *>----------------------------------------------------------------
      *>
      *>
      *>
      *>----------------------------------------------------------------
      *>
       ENVIRONMENT DIVISION.
       DATA DIVISION .
       WORKING-STORAGE  SECTION.
    
       01 EXPONENT  PIC 9(38)        COMP-3 .
       01 FIELD-01  PIC S9(1)V9(37)  COMP-3 .
       01 RESULT    PIC S9(38)        COMP-3 .
    
      *>
       PROCEDURE DIVISION .
      *>-------------------
      *>
           move -1.0000000000000000047432887442980750246  to field-01 .
           move 18446744073709551616 to exponent .
           compute result = field-01 ** exponent
             on size error
                 display 'Should not size error'
             not on size error
                 if result NOT = 99999999999999999882232070383165808731
                 THEN
                     DISPLAY 'result <'
                        result
                     '> != 99999999999999999882232070383165808731'
                 END-IF
           end-compute .
      *>
           GOBACK .
      *>
    
     
    • Simon Sobisch

      Simon Sobisch - 2024-09-25

      Am 25.09.2024 um 17:20 schrieb Denis HUGONNARD-ROCHE:

      Hi Simon
      Here is an example.

      Thanks!

      I have a hudge patch that include bug fixes #924, #925, #989 and a full testing suite for power compute.
      I will send it as a pull request to the ocaml repository .

      Please try to create separate PRs for each bug that is not totally
      intermixed with another one.

      Thank you,
      Simon

       
  • Denis HUGONNARD-ROCHE

    Hum difficult to push separates PR as i have deeply modified the cob_decimal_pow function

     
    • Simon Sobisch

      Simon Sobisch - 2024-09-25

      Hum difficult to push separates PR as i have deeply modified the cob_decimal_pow function

      Just see what you can separate; I'd likely keep everything that involves
      functions like the mentioned in one patchfile/PR.

       
  • Denis HUGONNARD-ROCHE

    Hi Simon
    I have sent the PR, first time i use Github ... hope it's ok :-)
    PR #182

    Denis

     
  • Mickey White

    Mickey White - 2024-09-26

    When will these 3 bug fixes be loaded to the nightly build for 3.3 ?

     
    • Simon Sobisch

      Simon Sobisch - 2024-09-26

      As soon as I took the time to review and check-in upstream... as I commonly don't work 40h+ per week on GnuCOBOL this likely takes some time, in the meanwhile you could use the nightly tarball and apply the patches yourself (if you only use the nightly binaries that need to wait until this is "upstream available".

      Note that there's already a bunch of stuff in the review queue of things sent by mail, via OCamlPro's GH mirror and even older changes from myself and there are pending issues I'm working on as well (apart from work ;-)

       
      • Denis HUGONNARD-ROCHE

        Hi Simon
        I noticed the comment on github and i will modify the code as you adviced.
        But i have a question before .
        While reading IBM Cobol 6.4, i saw that regarding exponentiation (cf attached file)
        Is it a standard Cobol rule, an IBM rule ?
        Do we have to stick to IBM rule for better compatibility ?
        What MF says about this cases ?

        Denis

         
        😄
        1

Log in to post a comment.