Microsoft KB Archive/36078

How to Use Hexadecimal Literal Constants in COBOL 3.0

PSS ID Number: Q36078 Article last modified on 04-20-1993

3.00 | 3.00 MS-DOS | OS/2

Summary: One excellent feature of COBOL Version 3.0 is the ability to express numbers in their hexadecimal form in a literal constant. Use an X prefix before the quotes for a hexadecimal number loaded in an alphanumeric field. Use an H prefix before the quotes for a hexadecimal number loaded in a numeric field. The following program segment demonstrates some valid forms of hexadecimal constants: DATA DIVISION. WORKING-STORAGE SECTION. 77 HEX-NUM-1 PIC X(4) VALUE X“FFEB”. 77 HEX-NUM-2 PIC 9(4) VALUE H“FFEB”. PROCEDURE DIVISION. 000-MAIN. MOVE X“ABCD” TO HEX-NUM-1. MOVE H“BBBB” TO HEX-NUM-2. STOP RUN.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.