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

value movement in cobol


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jaspal

New User


Joined: 22 May 2007
Posts: 68
Location: mumbai

PostPosted: Fri Feb 12, 2010 9:08 pm
Reply with quote

Hi friends,

what will be the value in field $$$$9.999 if i move 456.67 into it.

thanks,
Jaspal
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Fri Feb 12, 2010 9:25 pm
Reply with quote

RTFM
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: Fri Feb 12, 2010 11:11 pm
Reply with quote

Hello Jaspal,

For questions of this type, it would be far faster to run an experiment on your system. Most programmers have a tiny source module (one for each programming language they use) that is only used for such experiments. If you don't have one, create one - takes about 5 minutes.

Run the experiment and if there are problems that are not clear after looking in the manual, post back here with what you tried, what happened, and your doubt about it.

Someone will be able to clarify.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Feb 13, 2010 7:35 am
Reply with quote

... and if you don't have access to a mainframe, check the MOVE statetement and PICTURE clauses in the COBOL Language Reference Manual.
Back to top
View user's profile Send private message
Kylash V

New User


Joined: 13 Feb 2010
Posts: 5
Location: Chennai

PostPosted: Sat Feb 13, 2010 11:33 pm
Reply with quote

Hi Jaspal
The value would be B$456.67 where B indicates blank spaces. The repeated $ symbol in the PIC clause would indicate that this is a floating sign. So for eg. if you were to move 6.67 to this variable, you would get BBB$6.67
If you wanted a fixed $ symbol (wrt position) to the left of your number, you could declare your variable as $Z(4)9.999.

Hope this clarifies
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: Sun Feb 14, 2010 2:15 am
Reply with quote

Kylash, your answer is nearly right -- but still wrong. Code
Code:
           05  WS-VAR1                 PIC $$$$9.999  .
      *
       PROCEDURE DIVISION.
       S1000-INITIALIZE.
           MOVE 456.67                 TO  WS-VAR1.
           DISPLAY 'WS-VAR1:/' WS-VAR1 '/'.
produces output of
Code:
 WS-VAR1:/ $456.670/
Any extra positions after the decimal point will become zero and with three digits specified, you missed the final zero that will be present.
Back to top
View user's profile Send private message
Kylash V

New User


Joined: 13 Feb 2010
Posts: 5
Location: Chennai

PostPosted: Sun Feb 14, 2010 10:51 am
Reply with quote

Hi Robert,
Yes. I had missed the last zero after the decimal. Thanks for correcting the error.
Guess thats where experience comes in icon_smile.gif
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: Sun Feb 14, 2010 11:27 am
Reply with quote

Quote:
Guess thats where experience comes in
Partly.

More importantly, one should test before posting. It only wastes everyone's time to deal with incorrect/untested "solutions". . . icon_sad.gif

Worse, someone else who reads the "solution" before the correction is posted will haved recieved wrong information. . . The intent of our forum is to provide solid information, not just what we might happen to think.

Please do not post anything else without posting the test results proving the solution.

d
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Mar 01, 2010 7:10 am
Reply with quote

One final caution, jaspal:

If you move a numeric variable containing a negative value to the Edited variable you describe, it will be treated as a positive value.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top