IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

PL/I Decimal sign


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 02, 2011 7:59 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon May 02, 2011 8:06 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 02, 2011 8:14 pm
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: 1788
Location: Bloomington, IL

PostPosted: Mon May 02, 2011 8:38 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 02, 2011 10:06 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 04, 2011 7:44 pm
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed May 04, 2011 9:20 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed May 04, 2011 9:29 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 04, 2011 9:49 pm
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

Senior Member


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

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

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed May 04, 2011 9:55 pm
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: 1788
Location: Bloomington, IL

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

Phrzby Phil wrote:
CROMULENT?

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

Senior Member


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

PostPosted: Wed May 04, 2011 10:46 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed May 04, 2011 10:52 pm
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: 1788
Location: Bloomington, IL

PostPosted: Wed May 04, 2011 11:05 pm
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

Senior Member


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

PostPosted: Wed May 04, 2011 11:10 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 05, 2011 5:11 am
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: 1788
Location: Bloomington, IL

PostPosted: Thu May 05, 2011 3:59 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 05, 2011 4:08 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts String has hex character need to conv... COBOL Programming 3
No new posts How to display the leading zeros of a... DB2 7
Search our Forums:

Back to Top