Interpreting COMP-3 Packed Decimal Fields into Numeric Values

I am creating an SSIS package to read in unpacked data from a series of notebook files. I am not sure of the correct interpretation of the following field definitions and was hoping that someone would find out:

FIELD-NAME-1 PIC S9 (15) V9 (3) COMP-3.
FIELD-NAME-2 PIC S9 (3) V9 (8) COMP-3.
FIELD-NAME-3 PIC S9 (3) V9 (6) COMP-3.

Data is stored in fixed-width text. The data for the specified fields has the following lengths:

FIELD-NAME-1: 19 FIELD-NAME-2: 11 FIELD-NAME-3: 9

I am not sure how to interpret the decimal place and sign.

Any help would be greatly appreciated.

Regards Ham

+5
source share
5 answers

.

PIC S9 (15) V9 (3) COMP-3 :

    00 00 00 00 00 00 00 00 00 0F

-4568248.323, :

    00 00 00 00 04 56 82 48 32 3D

, . :

F0 F0 F0 F0 F0 F0 F0 F0 F0 F4 F5 F6 F8 F2 F4 F8 F3 F2 D3 (or F3 as the last byte, therefore losing the sign)

15 ( 16) 3 .

18 (15 + 3), 19, ( ​​ , 10 ). , .

** , C F , D . (D), , .

** "V" - . , COBOL , .. . , , .

, , , , .

, , - .

+4

:

PIC - ""
S9 (15) 15- : S , 9 - , (15) - . V - 9 (3) -

COMP-3 - - . nybble () ,

0b01110110 (duh)

- "76".

18 9 , - .

, 10.

.

+2

COMP-3 BCD , , (4 ). . 13, , - ( 12), . .

, -1.2 , D .

   01 2D

12.345:

   12 34 5C
+2

COMP-3 , + 1, 2. , 987, 3 +1, 2 = 2. , Comp- 3 2 +999 -999 .

15 015C. , C D, "C" , "D" . 4 .

, 7- 7 +1 = 8/2 = 4 . , comp-3 4 +999,9999 -999,9999 .

, , .

FIELD-NAME-3 PIC S9 (3) V9 (6) COMP-3.

we need to define a decimal field, for example DEC-PORTION V9 (6) comp-3, and then move FIELD-NAME-3 to DEC-PORTION to save the decimal part of the value.

Thus, we can have the decimal part of a number separated from the full number.

+1
source

All Articles