|
|
| Author |
Message |
birdy K
New User
Joined: 05 Mar 2008 Posts: 45 Location: chennai
|
|
|
|
Hello everybody,
I need -0 value. So I thought ,
01 fval pic -9(05) value zero.
01 sval pic s9(06).
01 tval pic s9(05) comp-3.
If i move from fval to sval. and Then move from sval to tval. I will get
-0. I didnt test it that. Can anyone tell whether this will work perfectly?
I think I am right. If there is anything wrong. Please forgive me. |
|
| Back to top |
|
 |
References
|
Posted: Fri May 09, 2008 12:06 pm Post subject: Re: Comp-3 to hold negative Zero |
 |
|
|
 |
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 169 Location: Bangalore
|
|
|
|
| first of all, tell me the meaning and use of the value (-0) |
|
| Back to top |
|
 |
birdy K
New User
Joined: 05 Mar 2008 Posts: 45 Location: chennai
|
|
|
|
| Hai gautam I need to display as such. |
|
| Back to top |
|
 |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 169 Location: At my Desk
|
|
|
|
| birdy K wrote: |
Hello everybody,
I need -0 value. So I thought ,
01 fval pic -9(05) value zero.
01 sval pic s9(06).
01 tval pic s9(05) comp-3.
If i move from fval to sval. and Then move from sval to tval. I will get
-0. I didnt test it that. Can anyone tell whether this will work perfectly?
I think I am right. If there is anything wrong. Please forgive me. |
why can not you try and let us know the results? |
|
| Back to top |
|
 |
birdy K
New User
Joined: 05 Mar 2008 Posts: 45 Location: chennai
|
|
|
|
Thank you sri . I tried . Its not working fine.
Is there any other way to get -0 value? |
|
| Back to top |
|
 |
ashimer
Senior Member
Joined: 13 Feb 2004 Posts: 313 Location: Bangalore
|
|
|
|
| You cannot move fval to sval it will give you error cos you are moving a numeric edited field. |
|
| Back to top |
|
 |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 169 Location: At my Desk
|
|
|
|
| birdy K wrote: |
Thank you sri . I tried . Its not working fine.
Is there any other way to get -0 value? |
U have to use editing data types to display that.
Ex: 01 fval pic -9(05) value zero.
display FVAL.
Correct me if i m wrong. |
|
| Back to top |
|
 |
ashimer
Senior Member
Joined: 13 Feb 2004 Posts: 313 Location: Bangalore
|
|
|
|
If you just need to display -0 and no computations involved then do this
01 fval pic x(2).
move x'60F0' to fval
this will give the value of fval as -0.
thanks,
ashimer |
|
| Back to top |
|
 |
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 169 Location: At my Desk
|
|
|
|
| ashimer wrote: |
If you just need to display -0 and no computations involved then do this
01 fval pic x(2).
move x'60F0' to fval
this will give the value of fval as -0.
thanks,
ashimer |
ashimer its workibg fine. can u explain it.
I tried this.
01 TVAL PIC S9(05) COMP-3 VALUE ZERO.
01 FVAL PIC -9(05).
Move tval to fval.
Display fval.
But it is displaying zeros only. No negative sign.Can any one throw some lite on this. |
|
| Back to top |
|
 |
ashimer
Senior Member
Joined: 13 Feb 2004 Posts: 313 Location: Bangalore
|
|
|
|
The hex value for -0 is 60F0... i just moved this value to fval ...
here you tval even though its s9(5) it wont have a sign over here as the value is 0 and you are moving this value ie zero to fval .. |
|
| Back to top |
|
 |
birdy K
New User
Joined: 05 Mar 2008 Posts: 45 Location: chennai
|
|
|
|
| I need this in comp-3 field. |
|
| Back to top |
|
 |
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 169 Location: Bangalore
|
|
|
|
earlier you said that you have to display it in that format (-0).
now you are saying that you want it to be in a COMP-3 variable.
are you willing to say that you are displaying a COMP-3 variable. |
|
| Back to top |
|
 |
birdy K
New User
Joined: 05 Mar 2008 Posts: 45 Location: chennai
|
|
|
|
No I am not displaying comp-3 field. My work is to move from assembler to cobol. In assembler coding they are moving -0 to display. So the same way I have to do.
I tried this
01 fval pic x(06) value '00000}'
01 tsval redefines fval.
05 sval pic s9(06).
01 tval pic s9(05) comp-3.
move fval to tsval. Now sval value is -000000. But while moving from sval to tval. It is showing as +00000. I am seeing this values in xpeditor. |
|
| Back to top |
|
 |
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 169 Location: Bangalore
|
|
|
|
its obvious that you will not get it directly, since 0 is not a negative value.
since, you just have to display it, why dont you use the code that ashimer posted. |
|
| Back to top |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 970 Location: Virginia, USA
|
|
|
|
1. -0 is a meaningless term.
2. The basic rules of COBOL prohibit -0. |
|
| Back to top |
|
 |
|
|