Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

PL/I Decimal sign

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon May 02, 2011 7:59 pm    Post subject: PL/I Decimal sign
Reply with quote

In the fine IBM Cobol manual, it says, if you want to call PL/I or Fortran from your Cobol program, you have to set a compiler option which allows "non-preferred" signs in decimal fields.

So, instead of just C/D and F, the option allows A, B, C, D, E and F to be valid for a zoned- or packed-decimal.

Does anyone know why?

Thanks in advance.
Back to top
View user's profile Send private message

prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Mon May 02, 2011 8:06 pm    Post subject:
Reply with quote

I haven't got the foggiest idea. In the 25 years of using PL/I, I've never ever seen any A, B or E signs in any PL/I fixed decimal, even getting F signs n PL/U is pretty rare.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon May 02, 2011 8:14 pm    Post subject: Reply to: PL/I Decimal sign
Reply with quote

Thanks Prino, that was quick :-)

Now, where's the FORTRAN forum....?

Here's the quote from the Programmer's Guide:

Quote:

Using NUMPROC(PFD) can affect class tests for numeric data. You should use
NUMPROC(NOPFD) or NUMPROC(MIG) if a COBOL program calls programs written in
PL/I or FORTRAN.


Perhaps the IBM Cobol people don't trust the results that might come back from PL/I or FORTRAN? Could it actually be something for LE?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Mon May 02, 2011 8:38 pm    Post subject: Re: PL/I Decimal sign
Reply with quote

Bill Woodger wrote:
In the fine IBM Cobol manual, it says, if you want to call PL/I or Fortran from your Cobol program, you have to set a compiler option which allows "non-preferred" signs in decimal fields.

So, instead of just C/D and F, the option allows A, B, C, D, E and F to be valid for a zoned- or packed-decimal.

Does anyone know why?

OS/360 and 360/n machines did define any non-decimal digit in the sign nybble to be valid; A,C, and E were positive, B and D were negative, and F was unsigned.

It has, as Mr. Prins intimates, been decades since anything running on a 360 or successor has actually produce a packed decimal number with an A, B, or E in the sign nybble. But it's still technically valid, and therefore must be handled.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon May 02, 2011 10:06 pm    Post subject: Reply to: PL/I Decimal sign
Reply with quote

Thanks Mr Akatsukami. Makes sense. I'll make a wild guess that the same thing applies to FORTRAN, if I ever need to know that :-)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed May 04, 2011 7:44 pm    Post subject: Reply to: PL/I Decimal sign
Reply with quote

From the POP.

Quote:

The preferred sign codes are 1100 for plus and 1101 for minus. These are the sign codes generated for the results of the decimal-arithmetic instructions and the CONVERT TO DECIMAL instruction.

Alternate sign codes are also recognized as valid in the sign position: 1010, 1110, and 1111 are alternate codes for plus, and 1011 is an alternate code for minus. Alternate sign codes are accepted for any decimal source operand, but are not generated in the completed result of a decimal-arithmetic instruction or CONVERT TO DECIMAL. This is true even when an operand remains otherwise unchanged, such as when adding zero to a number. An alternate sign code is, however, left unchanged by MOVE NUMERICS, MOVE WITH OFFSET, MOVE ZONES, PACK, and UNPACK.


So, if anyone does call PL/I or FORTRAN from Cobol, either compile the program with NUMPROC(NOPFD/MIG) (as IBM suggests) or, if you don't want to use NOPFD/MIG,

Code:

ADD ZERO TO data-name GIVING data-name

for each decimal (zoned or packed) returned from the called program. That will take care of the non-preferred signs, should they ever appear.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Wed May 04, 2011 9:20 pm    Post subject: Re: Reply to: PL/I Decimal sign
Reply with quote

Bill Woodger wrote:

So, if anyone does call PL/I or FORTRAN from Cobol, either compile the program with NUMPROC(NOPFD/MIG) (as IBM suggests) or, if you don't want to use NOPFD/MIG,
Code:
ADD ZERO TO data-name GIVING data-name

for each decimal (zoned or packed) returned from the called program. That will take care of the non-preferred signs, should they ever appear.

Of course this will only happen if the compiler isn't smart enough to optimize the whole statement away, a it really should be doing!
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed May 04, 2011 9:29 pm    Post subject:
Reply with quote

FWIW, since I had the test setup from the unsigned decimal "problem", I changed a sign nybble to A. Both BMC Load+ and DB2 found this to be cromulent.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed May 04, 2011 9:49 pm    Post subject: Re: Reply to: PL/I Decimal sign
Reply with quote

prino wrote:
Bill Woodger wrote:

So, if anyone does call PL/I or FORTRAN from Cobol, either compile the program with NUMPROC(NOPFD/MIG) (as IBM suggests) or, if you don't want to use NOPFD/MIG,
Code:
ADD ZERO TO data-name GIVING data-name

for each decimal (zoned or packed) returned from the called program. That will take care of the non-preferred signs, should they ever appear.

Of course this will only happen if the compiler isn't smart enough to optimize the whole statement away, a it really should be doing!


I'll have to check that out, but I think it will keep it, because of what the POP says. It is not only adding zero (or doing nothing, as another way of putting it, so suitable for removal) it is also ensuring that the sign is "preferred", so doing "something" (so not suitable for removal).
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Wed May 04, 2011 9:52 pm    Post subject:
Reply with quote

CROMULENT?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed May 04, 2011 9:55 pm    Post subject:
Reply with quote

Akatsukami wrote:
FWIW, since I had the test setup from the unsigned decimal "problem", I changed a sign nybble to A. Both BMC Load+ and DB2 found this to be cromulent.


And if you get hold of the field, calculate the value (say add zero to it) and stick it back in, it will be "preferred" again.

Perhaps there is a use for this. To find out which fields have never any any sort of calculation done on them. This is a joke. Or is it...
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed May 04, 2011 10:05 pm    Post subject:
Reply with quote

Phrzby Phil wrote:
CROMULENT?

Cromulent
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Wed May 04, 2011 10:46 pm    Post subject:
Reply with quote

Can't wait to play Scrabble again.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed May 04, 2011 10:52 pm    Post subject:
Reply with quote

It's tough to play 9-letter words in Scrabble. Although my record is an 11-letter word, built up over 4 turns.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed May 04, 2011 11:05 pm    Post subject:
Reply with quote

If we're playing SMScrabble, we could play "crmlnt". Srsly. icon_lol.gif
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Wed May 04, 2011 11:10 pm    Post subject:
Reply with quote

I think I did JO, JOE, JOEY, JOEYS once.

Best go was SWITCHED over two triple-words + bingo for 230 points for the go and 512 for the game.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu May 05, 2011 5:11 am    Post subject: Re: Reply to: PL/I Decimal sign
Reply with quote

prino wrote:
Of course this will only happen if the compiler isn't smart enough to optimize the whole statement away, a it really should be doing!


Away from Scrabble for the moment.

Code:

00037A  F822 D0F0 D0F0          ZAP   240(3,13),240(3,13)


This is a little doozy actually generated by the Cobol compiler to do the sign "fixing" (with a particular compiler option) of non-preferred to preferred. This, for definite, the optimiser does not remove. The ADD ZERO... is the closest I can get in Cobol code to the same thing.

"Doctor, doctor, I think I might have a non-preferred sign!", "Oh, go ZAP yourself!".
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu May 05, 2011 3:59 pm    Post subject: Re: Reply to: PL/I Decimal sign
Reply with quote

Bill Woodger wrote:
prino wrote:
Bill Woodger wrote:

So, if anyone does call PL/I or FORTRAN from Cobol, either compile the program with NUMPROC(NOPFD/MIG) (as IBM suggests) or, if you don't want to use NOPFD/MIG,
Code:
ADD ZERO TO data-name GIVING data-name

for each decimal (zoned or packed) returned from the called program. That will take care of the non-preferred signs, should they ever appear.

Of course this will only happen if the compiler isn't smart enough to optimize the whole statement away, a it really should be doing!


I'll have to check that out, but I think it will keep it, because of what the POP says. It is not only adding zero (or doing nothing, as another way of putting it, so suitable for removal) it is also ensuring that the sign is "preferred", so doing "something" (so not suitable for removal).

I think that that indicates the difference between "abstract COBOL" and "COBOL as she is implemented". In the abstract, that statement does do nothing, and so can be optimized away. To the left, the pseudo-assembler generated by the compiler does not do nothing (it generates a ZAP, which rectifies the sign), and thus a really smart optimizer would leave it. An optimizing COBOL compiler written for a non-z machine might not generate anything analogous to a ZAP, and could thus really optimize that statement to a comment.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Thu May 05, 2011 4:08 pm    Post subject: Reply to: PL/I Decimal sign
Reply with quote

I agree. Fun, isn't it. Like the dog that didn't bark, in a way.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts conversion from char to packed decimal Musab Ahmed DFSORT/ICETOOL 7 Fri Apr 08, 2016 1:12 pm
No new posts SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us