Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. HEX2DEC.
000003 ENVIRONMENT DIVISION.
000004 CONFIGURATION SECTION.
000005 DATA DIVISION.
000006 WORKING-STORAGE SECTION.
000007 01 I PIC S9(4) COMP-3.
000008 01 J PIC S9(4) COMP-3.
000009 01 K PIC S9(4) COMP-3.
000010 01 NN PIC XX VALUE LOW-VALUES.
000011 01 NN-R REDEFINES NN.
000012 02 FILLER PIC X.
000013 02 N-X PIC X.
000014 01 N REDEFINES NN PIC 9(4) COMP-4.
000015 01 X-18 PIC X(18) VALUE SPACES.
000016 01 X-18-R REDEFINES X-18.
000017 02 VEC-X-18 PIC X OCCURS 18.
000018 01 N-18-X.
000019 02 N-18 PIC 9(18) COMP-4.
000020 01 N-18-X-R REDEFINES N-18-X.
000021 02 VEC-N-18 PIC X OCCURS 8.
000022 01 F-18 PIC ----,---,---,---,---,---.
000023 01 XX PIC XX VALUE LOW-VALUES.
000024 01 XX-R REDEFINES XX.
000025 02 FILLER PIC X.
000026 02 X PIC X.
000027 01 X-9 REDEFINES XX PIC 9(4) COMP-4.
000028 01 VECTOR.
000029 02 VEC PIC X OCCURS 18.
000030 01 VECTOR-HEX PIC X(132)
000031 VALUE "00000001000200030004000500060007000800090010001100@A01
000032- "1200130014001500000016003200480064008000960112012801@B
000033- "44016001760192020802240240 ". @C
000034 01 VECTOR-HEX REDEFINES VECTOR-HEX.
000035 02 VEC-HEX PIC 9(4) OCCURS 32.
000036 01 VECTOR-OUT.
000037 02 VEC-OUT PIC X OCCURS 9.
000038*********************************************************************
000039 PROCEDURE DIVISION.
000040 MAIN SECTION.
000041 1. DISPLAY "ENTER HEX VALUES:".
000042 ACCEPT X-18.
000043 PERFORM HEX-TO-DEC.
000044 MOVE N-18 TO F-18.
000045 DISPLAY F-18.
000046 GOBACK.
000047 HEX-TO-DEC.
000048 MOVE X-18 TO VECTOR.
000049 MOVE LOW-VALUES TO VECTOR-OUT.
000050 MOVE 0 TO J.
000051 PERFORM HEX-TO-DEC2 THRU EX-HEX-TO-DEC
000052 VARYING I FROM 1 BY 2 UNTIL I > 9.
000053 MOVE 0 TO N-18.
000054 MOVE 8 TO K.
000055 PERFORM HEX-TO-DEC1 VARYING I FROM J BY -1 UNTIL I < 1.
000056 HEX-TO-DEC1.
000057 MOVE VEC-OUT(I) TO VEC-N-18(K).
000058 SUBTRACT 1 FROM K.
000059 HEX-TO-DEC2.
000060 MOVE 0 TO X-9.
000061 MOVE VEC(I) TO X.
000062 IF X NUMERIC SUBTRACT 31 FROM X-9 GIVING K
000063 ELSE IF X NOT < "A" AND NOT > "F"
000064 SUBTRACT 38 FROM X-9 GIVING K
000065 ELSE MOVE 77 TO I
000066 GO TO EX-HEX-TO-DEC.
000067 MOVE VEC-HEX(K) TO N.
000068 ADD 1 I GIVING K.
000069 MOVE 0 TO X-9.
000070 MOVE VEC(K) TO X.
000071 IF X NUMERIC SUBTRACT 47 FROM X-9 GIVING K
000072 ELSE IF X NOT < "A" AND NOT > "F"
000073 SUBTRACT 54 FROM X-9 GIVING K
000074 ELSE MOVE "0" TO VEC-X-18(K)
000075 MOVE 1 TO K.
000076 ADD VEC-HEX(K) TO N.
000077 ADD 1 TO J.
000078 MOVE N-X TO VEC-OUT(J).
000079 EX-HEX-TO-DEC.
For this dialog i suspect there is no need to consider base 16 numbers.Pertaining to a numbering system which uses 16 as the base