[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index

  • Alphanumeric receiving item:
    (The PICTURE of ITEMA is X(4).)
      ITEMA
    Value
    ITEMB
    Description
    ITEMB
    Contents
    a. ABCD PIC X(4) ABCD
    b. ABCD PIC X(6) ABCDss
    c. ABCD PIC X(6) JUST ssABCD
    d. ABCs PIC X(6) JUST ssABCs
    e. ABCD PIC XXX ABC
    f. ABCD PIC XX JUST CD
  • Alphanumeric edited receiving item:
    (The PICTURE of ITEMA is X(7).)
      ITEMA
    Value
    ITEMB
    Description
    ITEMB
    Contents
    a. 063080s XX/99/XX 06/30/80
    b. 30JUN80 99BAAAB99 30sJUNs80
    c. 6374823 XXXBXXX/XX/X 637s482/3s/s
    d. 123456s 0XB0XB0XB0XB 01s02s03s04s
  • Numeric edited sending item:
      ITEMA
    PICTURE
    ITEMA
    Value
    ITEMB
    PICTURE
    ITEMB
    Value
    a. Z,ZZZ.99- 1,234.56- 999.999- 234.560-
    b. ZZZ,ZZZ.99- ss1,234.56- $$$,$$$.99- s$1,234.56-
    c. $$$,$$$.99CR s$1,234.56CR $$$,$$$.99- s$1,234.56-
    d. $$$,$$$.99DB s$1,234.56DB ZZZ,ZZZ.99CR ss1,234.56CR
    e. +++++.99 +1234.56 ZZZZZ.99+ s1234.56+
    f. ++++++.99 s-1234.56 ZZZZZZ.99- ss1234.56-
    g. ----- .99 -1234.56 ZZZZZ.99DB s1234.56DB
    h. ------ .99 ss1234.56 $$,$$$.99 $1,234.56
    i. $$$$.99- $123.45- /XXBXXBXXBXX/ /$1s23s.4s5-/
    j. $$$$.99- $123.45- /99B99B99B99/ /00s00s01s23/

    6.8.23 MULTIPLY

    Function

    The MULTIPLY statement multiplies two numeric operands and stores the product in one or more data items.


    num

    is a numeric literal or the identifier of an elementary numeric item.

    rsult

    is the identifier of an elementary numeric item. However, in Format 2, rsult can be an elementary numeric edited item. It is the resultant identifier.

    stment

    is an imperative statement executed when an on size error condition has occurred.

    stment2

    is an imperative statement executed when no on size error condition has occurred.

    General Rules

    1. In Format 1, the value of num is multiplied by the value of the first rsult. The product replaces the current value of the first rsult. The process repeats for each succesive occurrence of rsult.
    2. In Format 2, the values of the two operands before the word GIVING are multiplied together. The product replaces the current value of each rsult.

    Additional References

    Examples

    Each of the examples assume these data descriptions and beginning values:

    INITIAL VALUES


         03  ITEMA  PIC S99 VALUE 4.                     4
         03  ITEMB  PIC S99 VALUE -35.                 -35
         03  ITEMC  PIC S99 VALUE 10.                   10
         03  ITEMD  PIC S99 VALUE 5.                     5
    
    1. Without GIVING phrase: RESULTS


      MULTIPLY 2 BY ITEMB.                       ITEMB = -70
      
    2. SIZE ERROR phrase:
      (When the SIZE ERROR condition occurs, the values of the affected resultant identifiers do not change.)


      MULTIPLY 3 BY ITEMB
        ON SIZE ERROR                            ITEMB = -35
           MOVE 0 TO ITEMC.                      ITEMC =   0
      
    3. NOT ON SIZE ERROR phrase:


      MULTIPLY 2 BY ITEMB
        ON SIZE ERROR                            ITEMB = -70
           MOVE 0 TO ITEMC
        NOT ON SIZE ERROR
           MOVE 1 TO ITEMC.                      ITEMC =   1
      
    4. END-MULTIPLY and MULTIPLY results with SIZE ERROR:
      (The stment in the SIZE ERROR phrase executes if any operation causes a size error condition. The first MULTIPLY statement terminates with END-MULTIPLY. The second MULTIPLY executes whether or not the SIZE ERROR condition occurs.)


        MULTIPLY 4 BY ITEMA ITEMB ITEMC
          ON SIZE ERROR
            MOVE 1 TO ITEMD
        END-MULTIPLY
        MULTIPLY 2 BY ITEMA ITEMB ITEMC
          ON SIZE ERROR
            ADD 1 TO ITEMD
        END-MULTIPLY.
      
      
      After First
      MULTIPLY
      After Second
      MULTIPLY
      ITEMA = 16 ITEMA = 32
      ITEMB = -35 ITEMB = -70
      ITEMC = 40 ITEMC = 80
      ITEMD = 1 ITEMD = 1


      If the initial value of ITEMB had been -20, a SIZE ERROR condition would not have occurred during the first MULTIPLY. However, the second MULTIPLY would have caused the condition:

      After First
      MULTIPLY
      After Second
      MULTIPLY
      ITEMA = 16 ITEMA = 32
      ITEMB = -80 ITEMB = -80
      ITEMC = 40 ITEMC = 80
      ITEMD = 5 ITEMD = 6


    Previous Next Contents Index