View previous topic :: View next topic
|
Author |
Message |
kappurajesh Currently Banned New User
Joined: 03 Apr 2004 Posts: 4 Location: India
|
|
|
|
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 |
|
|
priya
Moderator
Joined: 24 Jul 2003 Posts: 568 Location: Bangalore
|
|
|
|
For corresponding,
Use the same variable name and structure.
You CAN'T ACCEPT COMP-1 from input console. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Something went awry. That 1st pic x field s/b:
10 cf-exponent pic x(001). |
|
Back to top |
|
|
|