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

ADD CORRESPONDING, SUBTRACT CORR, MULTIPLY CORR


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

New User


Joined: 03 Apr 2004
Posts: 4
Location: India

PostPosted: Sat Apr 03, 2004 1:22 am
Reply with quote

How do work with ADD CORRESPONDING,SUBTRACT CORRE,MULTIPLY Corres?

Can I accept value for Comp -1 from user using accept command
Back to top
View user's profile Send private message
priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Sun Apr 04, 2004 9:40 pm
Reply with quote

For corresponding,

Use the same variable name and structure.

You CAN'T ACCEPT COMP-1 from input console.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Apr 05, 2004 3:48 am
Reply with quote

Hey K,

I've never worked w/comp-1/2 fields, but you might be able to do what you're asking. I's ugly, but might be do-able if the compiler allows redefinition of comp-1/2 fields.

Prompt your your terminal user to enter the exponent and the mantissa. Store them in separate fields and convert the values to COMP. Define the comp-1 field and redefine it as follows:

05 comp-1-fld.
05 constructed fld redefines comp-1-fld.
10 cpic x(001).
10 cf-mantissa pic x(003).

05 accept-exp pic 9(002).
05 accept-man pic 9(004).

05 comp-exp pic 9(001) comp.
05 comp-man pic 9(001) comp.


display 'enter 2 digit exp with leading zeros'
accept accept-exp
display 'enter 4 digit man with leading zeros'
accept accept-man

move accept-exp to comp-exp
move accept-man to comp-man
move comp-exp(2:1) to cf-exponent
move comp-man(2:3) to cf-mantissa

If you have to handle negative values too, it gets even stickier.

Regards, Jack.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Apr 05, 2004 3:53 am
Reply with quote

Something went awry. That 1st pic x field s/b:

10 cf-exponent pic x(001).
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 Subtract the ZD fields to provide neg... DFSORT/ICETOOL 4
No new posts Compare two files and subtract values DFSORT/ICETOOL 7
No new posts Sort to subtract constant from variab... DFSORT/ICETOOL 9
No new posts JCL SORT - Subtract 2 Months from Cur... SYNCSORT 12
No new posts How to subtract 100 days from current... DFSORT/ICETOOL 3
Search our Forums:

Back to Top