Previous PageTable Of ContentsIndex


7 COBOL/MVS PROGRAMMING AND RUNNING TIPS

7.1 Restrictions

7.2 Program Design and Efficiency

7.2.1 File Manipulation

7.2.2 Data Definition

7.2.3 Procedure Division

7.2.3.1 Carriage Control

7.3 Hints

7.4 Data Formats for Inter-Language Communication


Icon7 COBOL/MVS PROGRAMMING AND RUNNING TIPSIcon

In addition to the pointers given below, also consult the "Programming Techniques" section of the IBM COBOL for MVS & VM Programming Guide, SC26-4767.

7.1 Restrictions

7.2 Program Design and Efficiency

The hints in this section apply to all types of COBOL programs run at NIH.

7.2.1 File Manipulation

7.2.2 Data Definition

7.2.3 Procedure Division

7.2.3.1 Carriage Control

7.3 Hints

7.4 Data Formats for Inter-Language Communication

The following figures show the ways data can be stored. The source language definitions for each data type are given under the COBOL, FORTRAN, and PL/I headings. For more specific information on data formats, consult the appropriate language manuals and the IBM manual ESA/390 Principles of Operation, SA22-7201.

The "MACHINE DATA FORMAT" column in the figures below shows a bit breakdown of the data type as stored internally. Bit positions are written vertically under the machine data format symbols they refer to.

CHARACTER

COBOL

FORTRAN

PL/I

TYPE

PIC X(n)

DISPLAY

1<=n<=32767

CHARACTER*n

1<=n<=3267

CHAR(n)

1<=n<=32767

Length =

n bytes

MACHINE DATA FORMAT

EXAMPLE

Char 1

Char 2

...

Char n

Value

Internal hex

representation

0 0

-

0 7

0 1

-

8 5

   

ABCD

C1C2C3C4

Figure 2. Character Formats for Inter-Language Communication

FIXED POINT

The fixed point two-word data type, which is available only in COBOL, is simulated through software and requires all data items to be aligned on a word boundary.

The "Range" given in the table indicates the minimum and maximum values numbers can have in all uses of the language. Idiosyncrasies in languages reduce the full range of numbers in some cases even though they are represented the same internally.

Assumed decimal points in COBOL and PL/I are not shown in the table. They are stored in the same way as other numbers; instructions generated by the compilers keep track of the position of the assumed decimal point.

COBOL

FORTRAN

PL/I

TYPE

PIC S9(1-4)

COMP

(or COMP-4)

Range:

-9999 to 9999

INTEGER*2

Range:

-32768 to 32767

FIXED BIN

(1-15,0)

Range:

-32768 to 32767

Halfword

Length = 2 bytes.

PIC S9(5-9)

COMP

(or COMP-4)

Range:

-(9)9s to +(9)9s

INTEGER*4

Range:

-2147483648 to

2147483647

FIXED BIN

16-31,0)

Range:

-2147483648 to 2147483647

Fullword

Length =4 bytes.

PIC S9(10-18)

COMP

(or COMP-4)

Range:

-(18)9s to +(18)9s

-----

-----

Two-word

Length = 8 bytes.

Figure 3. Fixed Point Formats for Inter-Language Communication

MACHINE DATA FORMAT

EXAMPLES

    0 0 - 1

    0 1 5 Halfword

Value

----------+1234

-1234

Internal hex
representation

--------------------

04D2

FB2E

0 0 - 3

0 1 1 Fullword

+1234

----------

-1234

000004D2

---------------------

FFFFFB2E

0 0 - 6

0 1 3

Two-word

+1234

----------

-1234

0...04D2

---------------------

F...FB2E

"S" is a binary sign bit: 0 is positive; 1 is negative.
"I" is a 15, 31, or 63 bit integer.
Figure 4
(Continued)

FLOATING POINT

Magnitude is the range of a number expressed in powers of ten.

Although the numbers are represented the same internally, peculiarities in languages reduce the precision of numbers in some cases. The degree of precision given in the table is good in all cases. Fractional precisions occur because of the difference between the decimal representation and the machine's internal storage of numbers.

COBOL

FORTRAN

PL/I

TYPE

COMP-1

Magnitude:

10**-78 to 10**75

Precision:

7.2 digits

REAL*4

Magnitude:

10**-78 to 10**75

Precision:

7.2 digits

FLOAT

DEC(1-6)

Magnitude:

10**-78 to 10**75

Precision:

6 digits

Short

Length = 4 bytes

COMP-2

Magnitude:

10**-78 to 10**75

Precision:

16 digits

REAL*8

Magnitude:

10**-78 to 10**75

Precision:

16.8 digits

FLOAT

DEC(7-16)

Magnitude:

10**-78 to 10**75

Precision:

16 digits

Long

Length = 8 bytes

------

REAL*16

Magnitude:

10**-78 to 10**75

Precision:

35 digits

FLOAT

DEC(17-33)

Magnitude:

10**-78 to 10**75

Precision:

33 digits

Extended

Length = 16 bytes

Figure 4. Floating Point Formats for Inter-Language Communication

MACHINE DATA FORMAT

EXAMPLES

0 0-0 0 - 3

0 1 7 8 1

Short

Value

-----------

+1234

------------1234

Internal hex

representation

---------------------

434D2000

---------------------

C34D2000

0 0-0 0 - 6

0 1 7 8 3

Long

+1234

-----------

-1234

434D20...0

---------------------

C34D20...0

0 0-0 0 - 6

0 1 7 8 3

0 - 0 0 6

0 7 8 3

Extended

+1234

-----------

-1234

434D20...0

---------------------

C34D20...0

"S" is a binary sign bit: 0 is positive; 1 is negative.
"E" is a seven bit exponent with a value between hex 16** -64 and 16** +63.
"F" is a fraction, which may be 24, 56, or 112 bits long.
Figure 4
(Continued)

ZONED DECIMAL

The "Range" given in the table indicates the minimum and maximum values numbers can have in all uses of the language. Idiosyncrasies in languages reduce the full range of numbers in some cases even though they are represented the same internally.

COBOL

FORTRAN

PL/I

TYPE

PIC 9(n)

DISPLAY

1<=n<=18

Range: 0 to (18)9s

------

PIC '(n)9'

1<=n<=15

Range: 0 to (15)9s

Unsigned

Length = n bytes.

PIC S9(n)

DISPLAY

1<=n<=18

Range:

-(18)9s to +(18)9s

------

PIC '(n-1)9T'

1<=n<=15

Range:

-(15)9s to +(15)9s

Signed

Length = n bytes.

MACHINE DATA FORMAT

EXAMPLES

0-0 0-0 0-1 1-1

0 3 4 7 8 1 2 5

Unsigned

Value

----------

1234

Internal hex

representation

---------------------

F1F2F3F4

0-0 0-0 0-1 1-1

0 3 4 7 8 1 2 5

Signed

+1234

----------

-1234

F1F2F3C4

---------------------

F1F2F3D4

"Z" is a 4 bit zone code with a value of hex F.
"D" is a 4 bit binary decimal number with a value between hex 0 and 9.
"Si" is a 4 bit sign code: A, C, E, and F are positive; B and D are negative.

Figure 5. Zoned Decimal Formats for Inter-Language Communication

PACKED DECIMAL

The "Range" given in the table indicates the minimum and maximum values numbers can have in all uses of the language. Idiosyncrasies in languages reduce the full range of numbers in some cases even though they are represented the same internally.

COBOL

FORTRAN

PL/I

TYPE

COMP-3

PIC 9(n)

1<=n<=18

Range: -(18)9s to +(18)9s

------

FIXED

DEC(n)

1<=n<=15

Range: -(15)9s to +(15)9s

Length in

bytes = (n+1)/2 rounded up.

MACHINE DATA FORMAT

EXAMPLES

0-0 0-0

0 3 4 7

Value

---------------

-1234

---------------

-1234

Internal hex

representation

---------------------

01234C

---------------------

01234D

"D" is a 4 bit binary decimal number with a value hex 0 through 9.
"Si" is a 4 bit sign code: A, C, E, and F are positive; B and D are negative.

Figure 6. Packed Decimal Formats for Inter-Language Communication


Using COBOL at NIH - September 1998
Comments

Previous PageTop Of PageTable Of ContentsIndex