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.
01 WS-WORK-AREAS.
05 BIT-NBR PIC 9(04) COMP.
05 BIT-FLIPPER PIC 9(04) COMP VALUE 0.
05 FLD-1.
10 1ST-CHK-BYTE PIC X(01).
88 CHK-BIT-IS-ON VALUE X'80' THRU X'FF'.
88 CHK-BIT-IS-OFF VALUE X'00' THRU X'7F'.
10 FILLER PIC X(01).
05 CHK-BITS REDEFINES
FLD-1 PIC 9(04) COMP.
05 CHG-BITS PIC 9(04) COMP.
05 BIT-SHIFT-VALUES.
10 BIT-1 PIC 9(04) COMP VALUE 1.
10 BIT-2 PIC 9(04) COMP VALUE 2.
10 BIT-3 PIC 9(04) COMP VALUE 4.
10 BIT-4 PIC 9(04) COMP VALUE 8.
10 BIT-5 PIC 9(04) COMP VALUE 16.
10 BIT-6 PIC 9(04) COMP VALUE 32.
10 BIT-7 PIC 9(04) COMP VALUE 64.
10 BIT-8 PIC 9(04) COMP VALUE 128.
05 BIT-SHIFT-TBL REDEFINES
BIT-SHIFT-VALUES.
10 SHIFT-ENT PIC 9(04) COMP
OCCURS 8.
MOVE your data TO CHK-BITS(1:1)
CHG-BITS(1:1)
MOVE bit nbr TO BIT-NBR
MOVE ZEROS TO BIT-FLIPPER
MOVE X'80' TO BIT-FLIPPER(1:1)
COMPUTE CHK-BITS = CHK-BITS * SHIFT-ENT(BIT-NBR)
COMPUTE BIT-FLIPPER = BIT-FLIPPER / SHIFT-ENT(BIT-NBR)
EVALUATE TRUE
WHEN CHK-BIT-IS-ON
SUBTRACT BIT-FLIPPER FROM CHG-BITS
WHEN CHK-BIT-IS-OFF
ADD BIT-FLIPPER TO CHG-BITS
WHEN OTHER
DISPLAY 'HOUSTON WE HAVE A PROBLEM'
STOP RUN
END-EVALUATE
MOVE CHG-BITS(1:1) TO your receiving area
.
01 WS-WORK-AREAS.
05 FLD-1.
10 1ST-CHK-BYTE PIC X(01).
88 CHK-BIT-IS-ON VALUE X'80' THRU X'FF'.
88 CHK-BIT-IS-OFF VALUE X'00' THRU X'7F'.
10 FILLER PIC X(07).
05 CHK-BITS-64 REDEFINES
FLD-1 PIC 9(10) COMP.
05 CHG-BITS-64 PIC 9(10) COMP.
05 BIT-FLIPPER PIC 9(10) COMP VALUE ZEROS.
05 LOOP-CNTL PIC 9(04) COMP VALUE ZEROS.
05 BIT-LOC PIC 9(04) COMP VALUE ZEROS.
88 ONE-BIT VALUE 1 THRU 8.
88 BIT-STRING VALUE 0.
88 ERROR VALUE 9 THRU 65535.
MOVE your data TO CHK-BITS-64(1:nbr of bytes)
CHG-BITS-64(1:nbr of bytes)
MOVE nbr of bits TO LOOP-CNTL
MOVE ZEROS TO BIT-FLIPPER
MOVE X'80' TO BIT-FLIPPER(1:1)
PERFORM XXXX-CHK-A-BIT LOOP-CNTL TIMES
MOVE CHG-BITS-64(1:nbr of bytes)
TO your receiving area
.
XXXX-CHK-A-BIT.
EVALUATE TRUE
WHEN CHK-BIT-IS-ON
SUBTRACT BIT-FLIPPER FROM CHG-BITS-64
WHEN CHK-BIT-IS-OFF
ADD BIT-FLIPPER TO CHG-BITS-64
WHEN OTHER
DISPLAY 'HOUSTON WE HAVE A PROBLEM'
STOP RUN
END-EVALUATE
COMPUTE CHK-BITS-64 = CHK-BITS-64 * 2
COMPUTE BIT-FLIPPER = BIT-FLIPPER / 2
.
You wrote it from memory without compiling? You mean this code is not guaranteed to work at all? Why post it, then? You don't have to answer that...You can do that yourself, I was lazy...!
webrabbit said:I was wrong.
It is 2 x 10123, or 2 followed by 123 zeros.webrabbit said:2E+123 would be equal to 123 x 102.
webrabbit said:But the exponent of IBM internal floating point is 16, not 10.
IBM (and some other) floating point representations use 16 as the base of the exponent portion of the represented number, and therefore also use base-16 when normalizing the represented number, placing the radix point to the left of the most significant (hexadecimal) digit of the mantissa. IBM floating point is normalized so that the most significant hexadecimal digit is nonzero; other floating point schemes normalize down to the binary digit (and some, including IEEE, even normalize off the most significant 1 bit and then assume it thereby gaining more precision), and use 2 for the exponent base.webrabbit said:And of course, the mantissa is binary.