Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Comp-X behavior

$
0
0

This is not a bug.  PIC X(5) COMP-X only handles 12 digits fully; because it's binary, it partially handles the thirteenth digit, but cannot handle a number 9999999999999 (13 nines).  Its maximum value is 1099511627775 (a 12-digit number) with the value h"FFFFFFFFFF" (10 hex-digits).  Thus the compiler assigns a digit-length of 12.

In the latest versions of Visual COBOL, what you want could be described as Pic 9(13) Binary(5).  This describes a 13-digit item in a 5-byte binary item.  Moves using this as a sending item will move a 13-digit number to an alphanumeric item.  As described above, the 13-digit item cannot contain a value greater than 1099511627775, that is, not all 13-digit values are possible.

This sample program:

      01 Digits12      PIC X(5) COMP-X VALUE 1099511627775.

      01 Digits13      PIC 9(13) BINARY(5) VALUE 1099511627775.

      01 Alpha13       PIC X(13).

          move digits12 to alpha13.

          display "alpha13 from digits12 = """ alpha13 """".

          move digits13 to alpha13.

          display "alpha13 from digits13 = """ alpha13 """".

when run, displays:

       alpha13 from digits12 = "099511627775 "

       alpha13 from digits13 = "1099511627775"


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>