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

Variable's memory occupatioon


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
HozE

New User


Joined: 21 Feb 2007
Posts: 6
Location: Mumbai

PostPosted: Tue Dec 18, 2007 4:48 pm
Reply with quote

hi ALL,

I recently came across a variable defined as SPPPP99999

Any comments on how much memory will be occupied???
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Dec 18, 2007 10:03 pm
Reply with quote

Hello,

As this is something i'd not seen before, thought i'd give it a try.

Don't know what i expected, but what i got would not have been what i expected<g>. Maybe i've just done it "wrong".

The code
Code:
  01  SP9WORK.                       BLW=00000+098         0CL5
      05 SP9 PIC SPPPP99999.         BLW=00000+098,0000000 5C
   

 000-MOVEM.                         
     MOVE SPACES TO SP9WORK.         
     MOVE 123 TO SP9.               
     DISPLAY SP9WORK.               
     DISPLAY SP9.                   
     MOVE SPACES TO SP9WORK.         
     MOVE 987654321 TO SP9.         
     DISPLAY SP9WORK.               
     DISPLAY SP9.                   



The output
Code:
0000{   
0000{   
0000{   
0000{   
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Dec 18, 2007 10:32 pm
Reply with quote

HozE wrote:
hi ALL,

I recently came across a variable defined as SPPPP99999

Any comments on how much memory will be occupied???


It would be 5 bytes, the S shares a the byte with the last 9, and the Ps don't take up any bytes. Never have used the P except for training classes.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Dec 18, 2007 11:32 pm
Reply with quote

Hello,

Thoughts about how i got all zeros in the result?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Dec 19, 2007 12:05 am
Reply with quote

dick scherrer wrote:
Hello,

Thoughts about how i got all zeros in the result?


With the P on the left SPPPP99999 is a very small number with the decimal point before the leftmost P (.000099999).

Code:
5.3.11.1.1 P symbol 

 Because the scaling position character P implies an assumed decimal point (to the left of the Ps, if the Ps are leftmost PICTURE characters; to the right of the Ps, if the Ps are rightmost PICTURE characters), the assumed decimal point symbol, V, is redundant as either the leftmost or rightmost character within such a PICTURE description.
In certain operations that reference a data item whose PICTURE character-string contains the symbol P, the algebraic value of the data item is used rather than the actual character representation of the data item. This algebraic value assumes the decimal point in the prescribed location and zero in place of the digit position specified by the symbol P. The size of the value is the number of digit positions represented by the PICTURE character-string. These operations are any of the following:
 
Any operation requiring a numeric sending operand.
A MOVE statement where the sending operand is numeric and its PICTURE character-string contains the symbol P.
A MOVE statement where the sending operand is numeric-edited and its PICTURE character-string contains the symbol P and the receiving operand is numeric or numeric-edited.
A comparison operation where both operands are numeric.
In all other operations the digit positions specified with the symbol P are ignored and are not counted in the size of the operand.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2007 12:31 am
Reply with quote

Thanks Craig icon_smile.gif

'Preciat it.

Gee, i could've found it if i'd looked icon_redface.gif

d
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top