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

Reply via email to