Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comp-3 to hold negative Zero
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 12:06 pm    Post subject: Comp-3 to hold negative Zero
Reply with quote

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
View user's profile Send private message

the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Fri May 09, 2008 12:37 pm    Post subject:
Reply with quote

first of all, tell me the meaning and use of the value (-0)
Back to top
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 2:06 pm    Post subject:
Reply with quote

Hai gautam I need to display as such.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Fri May 09, 2008 2:18 pm    Post subject: Re: Comp-3 to hold negative Zero
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 2:48 pm    Post subject:
Reply with quote

Thank you sri . I tried . Its not working fine.
Is there any other way to get -0 value?
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 09, 2008 3:11 pm    Post subject:
Reply with quote

You cannot move fval to sval it will give you error cos you are moving a numeric edited field.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Fri May 09, 2008 3:17 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 09, 2008 3:25 pm    Post subject:
Reply with quote

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
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Fri May 09, 2008 3:30 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri May 09, 2008 3:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 3:41 pm    Post subject:
Reply with quote

I need this in comp-3 field.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Fri May 09, 2008 3:49 pm    Post subject:
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 4:31 pm    Post subject:
Reply with quote

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
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Fri May 09, 2008 5:04 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri May 09, 2008 5:05 pm    Post subject:
Reply with quote

1. -0 is a meaningless term.

2. The basic rules of COBOL prohibit -0.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 09, 2008 5:11 pm    Post subject:
Reply with quote

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
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Fri May 09, 2008 5:12 pm    Post subject:
Reply with quote

Thank u for all. My onsite told now not to include -. Anyway if anyone knows Please suggest.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 09, 2008 5:19 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri May 09, 2008 6:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Fri May 09, 2008 6:07 pm    Post subject:
Reply with quote

I have the same doubts as CICS Guy
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts How LOAD PROGRAM and LOAD on HOLD is ... pkmurali CICS 4 Tue May 03, 2016 6:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us