Menu

Move to numeric edited pic wrong results

2024-06-10
2024-06-24
  • Michael F Gleason

    When you move a negative value to a numeric edit item and the - sign would/should be where a , is a space is moved in front of the number.
    See attached program sample.
    Moving a data item with a value -100 to an edit item pic --,---,--9 should result as -100 not - 100.
    Michael :-)

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-10

    Michael,

    I have a new commit ready in which I have rewritten the function dealing with moving to a numeric edited field. So I'll test your code with my new version and post the results here.

         Chuck Haatvedt
    
     
  • Michael F Gleason

    Chuck
    If your gona test my code, here is some testing I did before submitting my original post.
    What I noticed is that moving a literal to an edit pattern will work at times that moving the same value from an identifier will fail.
    If you move an identifier-1 that defines more digits than the receiving identifier-2, it is not always handled correctly.
    See attach program and its' output.
    Michael :-)

     
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-11

    Michael,

    thanks for reporting this I think know what is causing the blank between the floating sign and the digits. I need to check what the cobol standard is for this condition.

    I know the issue for the following problem, but I need to work with Simon as COBC is generating the cob_field attributes incorrectly for this edited field...

    Note the number of digits should be 8 not 7.

    05  EX-2                    PIC $,$$$,$$9.99CR.
    
    this is from the GDB debugger
    
    (gdb) p COB_FIELD_DIGITS(dst) 
    $1 = 7   
    
    Results for EX-2 when input is an identifier are ALL messed up
    if identifier-1 is larger than identifier-2
      $100    $1,000.0+
     -$100    $1,000.0-CR <---<<< ALL ARE WRONG. ERROR.
     $1000   $10,000.0+
    -$1000   $10,000.0-CR
    

    Thanks again,

    Chuck Haatvedt

    patience, we are working on this...

     
    • Anonymous

      Anonymous - 2024-06-14

      PIC $,$$$,$$9.99CR.

      or, alternatively, with no $ sign

      PIC Z,ZZZ,ZZ9.99-

      libcob/common.h

      ** #define COB_FIELD_TYPE(f) ((f)->attr->type)
      ** #define COB_FIELD_DIGITS(f) ((f)->attr->digits) <-- DIGITS
      ** #define COB_FIELD_SCALE(f) ((f)->attr->scale) <- DECIMALS
      ** #define COB_FIELD_FLAGS(f) ((f)->attr->flags)
      ** #define COB_FIELD_PIC(f) ((f)->attr->pic)

      ** #define COB_FIELD_HAVE_SIGN(f) ((f)->attr->flags & COB_FLAG_HAVE_SIGN)
      ** #define COB_FIELD_SIGN_SEPARATE(f) ((f)->attr->flags & COB_FLAG_SIGN_SEPARATE)
      ** #define COB_FIELD_SIGN_LEADING(f) ((f)->attr->flags & COB_FLAG_SIGN_LEADING)

      :-)

       
    • Anonymous

      Anonymous - 2024-06-14

      Note the number of digits should be 8 not 7.

      05 EX-2 PIC [$,$$$,$$9].99[CR].

      No!

      Should be... seven!

      Sign is something else!

      :-)

       
      • Chuck Haatvedt

        Chuck Haatvedt - 2024-06-14

        run this program and count the number of digits in the output displays...

        If you wish to be helpful, then do some testing otherwise please refrain from attacking the work and efforts of those who are trying to help.

           Chuck Haatvedt
        
         
        👍
        2
  • Chuck Haatvedt

    Chuck Haatvedt - 2024-06-15

    please login when responding. It is best to know who we are replying to..

    In regards to the above, all is well. I may have responded a bit harshly during a long and difficult debugging period working on fixing bugs related to my efforts on cases involving moving / displaying NUMERIC DISPLAY EDITED data.

    I'm making progress and finally have a version which passes all the test cases included in the build regression testsuite. I've added a couple of additional tests to validate conditions which slipped through the testsuite before.

         Chuck Haatvedt
    
     
  • Michael F Gleason

    This issue has been resolved.
    Downloaded GNUCOBOL-X32-BDB from Chucks' post in GNUCOBOL forum.
    See topic New test build of GNUCOBOL 3.3dev...
    Michael :-)

     

    Last edit: Michael F Gleason 2024-07-17

Anonymous
Anonymous

Add attachments
Cancel