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

Display value 12345 as 1.2345


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

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Wed Jun 01, 2011 3:52 pm
Reply with quote

Hi!

I want to display value 12345 as 1.2345 using cobol program. How shall i do it?

I tried it with various options as one is given below but still its not working. Please suggest me suitable way.

WORKING-STORAGE SECTION.
01 WS-A PIC 9(5).
01 WS-B PIC X(5).
01 WS-C PIC Z.Z(4).
PROCEDURE DIVISION.
DISPLAY 'START OF PROGRAM'.
MOVE 12345 TO WS-A.
MOVE WS-A TO WS-B.
MOVE WS-B TO WS-C.
DISPLAY 'WS-C :' WS-C
STOP RUN.


In Sysout i got as:
START OF PROGRAM
WS-C :5.0000.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 01, 2011 4:04 pm
Reply with quote

Code:

working-storage section.
01  workareas.
     05  ws-a         pic 9(5).
     05  ws-b   
     redefines
         ws-a         pic 9v9(4).
     05  ws-c         pic z.z(4).
procedure division.
DISPLAY 'START OF PROGRAM'.
MOVE 12345 TO WS-A.
MOVE WS-B TO WS-C.
DISPLAY 'WS-C :' WS-C
STOP RUN.
Back to top
View user's profile Send private message
Vidya Kajale

New User


Joined: 01 Jun 2010
Posts: 43
Location: India

PostPosted: Wed Jun 01, 2011 4:17 pm
Reply with quote

thank u i got it.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 01, 2011 4:26 pm
Reply with quote

Bitte sehr
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jun 01, 2011 5:02 pm
Reply with quote

You can also divide the value by 10000
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 Jun 01, 2011 5:37 pm
Reply with quote

gylbharat wrote:
You can also divide the value by 10000


Yes, but why would you when Dick has the neatest and most obvious possible - plus efficient with CPU.
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 How to display the leading zeros of a... DB2 7
No new posts SDSF display Max-RC in different colors TSO/ISPF 4
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Unable to display comp variable COBOL Programming 4
No new posts Adding FIND to ISPF Panel display of ... TSO/ISPF 3
Search our Forums:

Back to Top