On Wed, Apr 24, 2013 at 7:43 AM, Phil Smith <[email protected]> wrote:
> Suppose you have values that you're converting between character and > packed decimal, in both directions at various times. You're a middleman, so > you don't know what the application is going to be using the values for. > > For a non-negative value, packed decimal could be either positive or > unsigned. > > What do folks usually do? Is it normal for code to actually care? That is, > if we say "Heck with it, we can't tell, so we'll just mark it positive", is > that likely to cause problems? Or is use of unsigned rare enough that this > is essentially a non-issue? (Hint: I'd like that last to be the case!) > Obviously a "sign=" value could be passed around with the value, but that > kind of metadata isn't in the stream now, so I'd rather not add it. > > Any and all ideas gratefully accepted... > It depends on how the packed data is used. If comparisons are always done using mathematical operators, then the sign bits will give results as expected. There are some places were the fields might not be checked for sign bits. 1) Sort control cards : SORT FIELDS=(1,5,A),FORMAT=BI 2) Assembler code that uses CLC to compare two packed fields 3) COBOL code that compares group level items with just 1 packed field subordinate. 3.1) 05 WS-PACKED-1 3.2) 10 WS-PACKED-1-1 pic S9(3) comp-3 value +1. 3.1) 05 WS-PACKED-2 3.2) 10 WS-PACKED-2-1 pic 9(3) comp-3 value 1. 3.3) If ws-packed-1 = ws-packed-2 3.3.1) Above will generate a CLC compare. 4) concatenated packed fields that are never used for math 4.1) 01 WS-BANK-KEY. 4.2) 05 WS-BRANCH pic s9(5) comp-3. 4.3) 05 ws-account pic s9(11) comp-3. 4.4) compares done as in 3.3 above. I've seen this used extensively where I currently work. They been on this road for 30 years. In Assembler it was easy to manage. Recently converted to COBOL and this makes for writing odd code. Original design was done to save the expense of CP vs. CLC. Now it is just painful. Sam ...phsiii > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
