10 date-convert-w. 15 packed-date-no-sign-w pic x(4). 15 date-packed-zero-w pic 9(1) packed-decimal value 0. 10 packed-date-w redefines date-convert-w pic 9(8)v9 packed-decimal.
move unsigned-packed-field to packed-date-no-sign-w. move date-packed-date-w to wherever. The destination field shouldn't have the implied decimal, so it will drop the temporary zero from the end. In this case it is a date; this is part of logic I use to extract the date and time from the STCK timestamp in IMS logs -- it is in TOD clock format. (The assembler version is a mvo + oi to set sign) -----Original Message----- From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Bernd Oppolzer Sent: Tuesday, April 29, 2025 6:19 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Packed decimal sign nibbles Topic drift: a really useful enhancemant for COBOL and other mainframe language IMO would be: the possibility to define DECIMAL variables, which are REALLY unsigned, that is, they don't have a sign nibble. x'00123456' as an example (8 decimal digits, unsigned). Because that's what we have all the time in legacy VSAM based systems, where clever architects of the past put numeric keys in packed decimal format WITHOUT SIGN in legacy datasets. Such fields (in key or non-key positions) are defined as CHAR fields, like PIC X(4) in the case above, but in reality they are something like PIC S9(8) COMP-3 "UNSIGNED". But because it is impossible to define it like that (at least in "my" version of COBOL - on VSE), we have to implement some logic to convert such fields to, say, PIC 9(8) USAGE DISPLAY, so that they can be shown on CICS screens or on the printer. Kind regards Bernd Am 29.04.2025 um 16:16 schrieb Schmitt, Michael: > In COBOL "unsigned" really means "not signed", which means that the number > can only have a positive value or zero. > > From a practical point of view: > > * An unsinged binary can hold larger numbers, depending on compile options > > * Unsigned is generally better for zoned decimal ("usage display"). 123 as a > signed zoned decimal (PIC S999) would be stored as x'F1F2C3', while as > unsigned (PIC 999) it would be F1F2F3. The problem is when you print or > display it: the signed version would print as 12C. I hate that. > > On the other hand, singed fields enable more efficient code. > > > Fun fact: CA Easytrieve also has signed and unsigned numbers, but there's no > obvious way to define it. The way it works is a number with decimal positions > is signed (aka "quantitative"), a number without is unsinged: > > Field 4 P = 4 byte unsigned packed decimal > Field 4 P 2 = 4 byte signed packed decimal with 2 decimal positions > > So how do you do a signed field with 0 decimals? Easy: > > Field 4 P 0 > > -----Original Message----- > From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of > Andrew Rowley > Sent: Monday, April 28, 2025 6:40 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: Packed decimal sign nibbles > > On 29/04/2025 9:32 am, Seymour J Metz wrote: >> The decimal instructions treat F zones as positive. > That's always been my understanding. But I'm intrigued by the statement > that it means unsigned in COBOL. Is there a practical difference? Or is > it just a difference e.g. for formatting output? > > -- > Andrew Rowley > Black Hill Software > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN