View previous topic :: View next topic
|
Author |
Message |
jaspal
New User
Joined: 22 May 2007 Posts: 68 Location: mumbai
|
|
|
|
Hi friends,
what will be the value in field $$$$9.999 if i move 456.67 into it.
thanks,
Jaspal |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
RTFM |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
... 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 |
|
|
Kylash V
New User
Joined: 13 Feb 2010 Posts: 5 Location: Chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Kylash V
New User
Joined: 13 Feb 2010 Posts: 5 Location: Chennai
|
|
|
|
Hi Robert,
Yes. I had missed the last zero after the decimal. Thanks for correcting the error.
Guess thats where experience comes in |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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". . .
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|