MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

usage of the P symbol in Cobol picture

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Sun Apr 12, 2009 5:16 pm    Post subject: usage of the P symbol in Cobol picture Reply with quote

hi there,

I wonder if someone could provide a practical example for the P symbol in the Cobol picture definition.

That's what I've got in a test I did:

Code:

01 w-variable pic 9(09)p comp-3.

move 123.456 to w-variable.
display 'w-var=' w-variable.

w-var= 000000056


I can't understand its purpose.

Thanks.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun Apr 12, 2009 8:15 pm    Post subject: Reply with quote

jctgf,

Hmm unless I am gravely mistaken shouldn't W-variable contain 12? instead of 56? You haven't defined a decimal point so only the integer part(123) is moved to w-variable and since you have P on the right , a decimal is assumed and the actual value would be 120 as having Symbol P assumes the decimal point in the prescribed location and zero in place of the digit position specified by the symbol P.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Mon Apr 13, 2009 5:52 am    Post subject: Reply with quote

yes, it may be 12 instead of 56.
i'm trying to guess the result i got at work, but i really don't remember.
as to the purpose, it's still a little bit blurred to me.
is the goal of the P symbol merely to replace the digit at that position for an 0?
could you provide an example of a situation in which it would be mandatory to use it, please?
thanks.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Apr 13, 2009 11:57 am    Post subject: Reply with quote

jctgf,

Well I don't have a practical example but I guess it can be used to calculate to the nearest integer involving decimals in a financial application.

As a simple example , an item costs $83.95 and the tax rate is 9.25% so when calculating the tax on $83.95 it would be 7.765375. Now using a P symbol they can round it down to 7.765370 or or 7.76530
or 7.7650

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Mon Apr 13, 2009 6:21 pm    Post subject: Reply with quote

thanks.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group