javaunixvbscriptcobolpacked-decimal

COBOL DATATYPE CONVERSION: Number to Packed Numeric, Packed Date COMP-3


I am trying to convert Number to PACKED DEMCIMAL, from web research number 123 will be 123D (C if negative number) as packed number, My question is "is this a correct PACKED DECIMAL?" because requirement that I have states, date will be stored in 3-byte packed number and length is only 2 digits.

Please explain or clear my doubt.


Solution

  • You have it backwards.

    A positive packed decimal ends in a C. A negative packed decimal ends in a D. An unsigned packed decimal, assumed to be positive, ends in an F.

    A 3 byte packed number contains 5 digits and a sign. PIC S9(5) COMP-3 is 3 bytes.

    I'm not sure what format your date is, if it's only five digits.