View previous topic :: View next topic
|
Author |
Message |
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 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 |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 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: 72 Location: chennai
|
|
|
|
Hai gautam I need to display as such. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
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: 72 Location: chennai
|
|
|
|
Thank you sri . I tried . Its not working fine.
Is there any other way to get -0 value? |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 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: 218 Location: India
|
|
|
|
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
Active Member
Joined: 13 Feb 2004 Posts: 551 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: 218 Location: India
|
|
|
|
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
Active Member
Joined: 13 Feb 2004 Posts: 551 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: 72 Location: chennai
|
|
|
|
I need this in comp-3 field. |
|
Back to top |
|
|
the_gautam
Active User
Joined: 05 Jun 2005 Posts: 165 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: 72 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: 165 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: 1512 Location: Virginia, USA
|
|
|
|
1. -0 is a meaningless term.
2. The basic rules of COBOL prohibit -0. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
birdy K wrote: |
Code: |
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. |
Because the COBOL compiler is insuring that the sign is correct and prevents the negetive value for zero.
Try
Code: |
01 fval pic x(03) value X'00000}'
01 tval pic s9(05) comp-3.
01 sval refefines tval pic x(3). |
When you move fval to sval, tval will be a -0..... |
|
Back to top |
|
|
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai
|
|
|
|
Thank u for all. My onsite told now not to include -. Anyway if anyone knows Please suggest. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
birdy K wrote: |
My onsite told now not to include -. Anyway if anyone knows Please suggest. |
Huh?
Not include the minus on the zero?
If anybody knows what?
Please suggest what? |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
I would be embarrassed to write a compiler that would let you have a value -0, and also embarrassed to show -0 on a report or screen.
In other words, what are the actual specs, and from what kind of user? |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
I have the same doubts as CICS Guy |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
birdy K
New User
Joined: 05 Mar 2008 Posts: 72 Location: chennai
|
|
|
|
Hai everybody
Sorry for the Delay. I was out of my station. Thank You CICS Guy. I asked How to include - sign with zero. Anyway It is meaningless. But Onsite asked me to do that. Now they dont need that. But I am interested to know. So I asked your suggestion. When I asked your suggestion. I didnt see CICS Guy post. Thank you for all. |
|
Back to top |
|
|
|