Microsoft KB Archive/36078

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

The information in this article applies to:
- Microsoft COBOL for MS-DOS and OS/2, version 3.0

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.