On 4/24/2013 9:19 AM, Bernd Oppolzer wrote:
My COBOL experience dates from the mid 80s, but

- I would suggest to always use signed values with comp-3 (packed), and to
mark values as positive, that have no explicit sign information

My sense is the OP is not necessarily working in COBOL; probably
Assembler.


And some questions:

- is it possible today to have comp-3 values in COBOL, that have no sign nibble?
In PL/1, for example, it is NOT possible to do this ... you have the UNSIGNED
attribute
only for BIN FIXED numeric data, not (yet) for DEC FIXED (CP et al. cannot 
handle
unsigned decimal data).

No. Comp-3 (or, better in today's COBOL, packed-decimal) data will
always have a sign nibble; but if you do not include an 'S' in the
PICTURE clause, the compiler adds code to force the sign to always
be positive after any arithmetic operation.



- if so, the generated CLC which compares such packed fields without sign 
nibbles
with fields which have sign nibbles would yield very strange results ...

The compiler generates CLC for compares between unsigned packed-decimal
data; if at least one of the comparands is signed, the CP instruction will
be used, and works just fine, thank you.


- I believe that you must make sure that CPs are generated for such comparisons,
because it's always possible that you get F sign nibbles instead of C for 
positive
signs (after PACK), and they should compare OK - and only CP tolerates different
sign nibbles

Kind regards

Bernd



Am 24.04.2013 16:43, schrieb Phil Smith:
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...

...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



--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
  + Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
    for training dollars at
  http://www.trainersfriend.com/ROI/roi.html

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to