Ethiopian multiplication: Difference between revisions

Replace PIC with PICTURE
(Added COBOL version)
(Replace PIC with PICTURE)
Line 605:
{{works with|OpenCOBOL|1.1}}
In COBOL, ''double'' is a reserved word, so the doubling functions is named ''twice'', instead.
<lang COBOL> *>* Ethiopian multiplication in COBOL
 
IDENTIFICATION DIVISION.
Line 611:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 l PICPICTURE 9(10) VALUE 17.
01 r PICPICTURE 9(10) VALUE 34.
01 ethiopian-multiply PICPICTURE 9(20).
01 product PICPICTURE 9(20).
PROCEDURE DIVISION.
CALL "ethiopian-multiply" USING
Line 630:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 evenp PICPICTURE 9.
88 even VALUE 1.
88 odd VALUE 0.
LINKAGE SECTION.
01 l PICPICTURE 9(10).
01 r PICPICTURE 9(10).
01 product PICPICTURE 9(20) VALUE ZERO.
PROCEDURE DIVISION using l, r, product.
MOVE ZEROES TO product
Line 664:
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 n PICPICTURE 9(10).
01 m PICPICTURE 9(10).
PROCEDURE DIVISION USING n, m.
DIVIDE n BY 2 GIVING m END-DIVIDE
Line 676:
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 n PICPICTURE 9(10).
01 m PICPICTURE 9(10).
PROCEDURE DIVISION USING n, m.
MULTIPLY n by 2 GIVING m END-MULTIPLY
Line 687:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 q PICPICTURE 9(10).
LINKAGE SECTION.
01 n PICPICTURE 9(10).
01 m PICPICTURE 9(1).
88 even VALUE 1.
88 odd VALUE 0.