Answer: Not a lot.  Basically you have to move the digits you have to a work 
field declared packed (COMP-3 unsigned) that is one byte longer than the 
source, where the additional byte has value X’0F’.  Move the source to the work 
field for just the length of the source field, then divide the work field by 10 
to get the original numeric value in a form you can use it in the rest of your 
COBOL program.

Peter

From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Seymour J Metz
Sent: Friday, May 2, 2025 5:02 PM
To: [email protected]
Subject: Re: Packed decimal sign nibbles

I can't speak to OP's situation, but we have packed fields containing only 
digits; we have to convvert using, e.g. MVO, before doing arithmetic with them. 
I'm curious as to what support COBOL and PL/I have for that format.  

-- 
Shmuel (Seymour J.) Metz
https://urldefense.com/v3/__http://mason.gmu.edu/*smetz3__;fg!!Ebr-cpPeAnfNniQ8HSAI-g_K5b7VKg!L91_-Omfx8zoWrNcQXBAhrK_UnkmXLzgeIB8afRLTD9_qLKoA-fsuZURrZ5tt_cDv4Qf4X9UmeHjUlxNsDnnkw$
עַם יִשְׂרָאֵל חַי
נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר

________________________________________
From: IBM Mainframe Discussion List on behalf of Bernd Oppolzer
Sent: Friday, May 2, 2025 9:07 AM
To: mailto:[email protected]
Subject: Re: Packed decimal sign nibbles


I would like to understand for the clarity of this discussion what you mean by 
unsigned packed decimal data;

is it simply pic 9(8) comp-3, where the internal representation has a sign 
nibble which should be always positive,

or is it (as often present in reality) a CHAR field containing decimal digits 
WITHOUT a sign nibble which neads byte twiddling to convert this to a usable 
number (which is TRUE UNSIGNED ... at least IMHO)?

Thanks, have a nice day

Bernd


Am 02.05.2025 um 14:30 schrieb Seymour J Metz:
> That's the right answer to the wrong question. OP asked about the generated 
> code, not about the requirements of specific instructions. Lots of 
> applications deal with unsigned packed decimal, and, yes, it requires more 
> instructions than signed packed decimal.
>
> --
> Shmuel (Seymour J.) Metz
> https://urldefense.com/v3/__http://mason.gmu.edu/*smetz3__;fg!!Ebr-cpPeAnfNniQ8HSAI-g_K5b7VKg!L91_-Omfx8zoWrNcQXBAhrK_UnkmXLzgeIB8afRLTD9_qLKoA-fsuZURrZ5tt_cDv4Qf4X9UmeHjUlxNsDnnkw$
> עַם יִשְׂרָאֵל חַי
> נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר
>
>
>
> ________________________________________
> From: IBM Mainframe Discussion List on behalf of Robin Vowels
> Sent: Friday, May 2, 2025 7:34 AM
> To: mailto:[email protected]
> Subject: Re: Packed decimal sign nibbles
>
>
> External Message: Use Caution
>
>
> On 2025-05-02 18:45, Andrew Rowley wrote:
>> On 2/05/2025 1:22 pm, Tom Ross wrote:
>>> Hmm, if you don't want a sign, why have an 'S' in the PICTURE clause?
>>> Signed:
>>>       05 SIGNED-ITEM  PIC S9(x) COMP-3.
>>> Unsigned:
>>>       05 UNSIGNED-ITEM  PIC 9(x) COMP-3.
>>>
>>> I guess I am too close to COBOL, but signed and unsigned are easy in COBOL!
>> What's the difference in the representation?
>> Is unsigned 1234:
>> 0x01234F
>> or
>> 0x001234
> To be handled by the hardware, the least-significant nibble must contain the 
> sign.
> Unsigned would contain a plus sign in this nibble.
--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.


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

Reply via email to