Search code examples
cobolgnucobol

Commas in cobol?


I'm still working with Cobol:) I have a question, let's take this code:

                          ACCEPT A
                           COMPUTE C= FUNCTION SIN(A)
                           END-COMPUTE
                          DISPLAY "Computing."
               DISPLAY "Computing.."
               DISPLAY "Computing..."
               DISPLAY "Computing...."
               DISPLAY "Computing....."
               DISPLAY "Computing......"
               DISPLAY "IL SENO DI " A " RISULTA..."
                           DISPLAY C " GRADI"

Now, it does Sinus, but the outup is, for example with 37: 00000000000000 GRADI My Scientific Calculator says: 0.6018 As you see COBOL does not show the numbers after comma. Is there a way to show them? Thank you:)


Solution

  • My cobol is not gnu, but you can do something like

    01 C comp-2.
    01 A pic 999.
    01 C1 pic 999.999999.
    
    PROCEDURE DIVISION.
    BEGIN.
           move 37 to A
           COMPUTE C = FUNCTION SIN(A)
           END-COMPUTE
           move C to C1
           DISPLAY "Computing."
           DISPLAY "Computing.."
           DISPLAY "Computing..."
           DISPLAY "Computing...."
           DISPLAY "Computing....."
           DISPLAY "Computing......"
           DISPLAY "IL SENO DI " A " RISULTA..."
                       DISPLAY C1 " GRADI"
    

    The actual output is

    Computing.
    Computing..
    Computing...
    Computing....
    Computing.....
    Computing......
    IL SENO DI 037 RISULTA...
    000.643538 GRADI