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

Comp-3 to hold negative Zero


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 218
Location: India

PostPosted: Fri May 09, 2008 2:18 pm
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
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
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: 218
Location: India

PostPosted: Fri May 09, 2008 3:17 pm
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
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: 218
Location: India

PostPosted: Fri May 09, 2008 3:30 pm
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
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
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
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
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
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
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: 2146
Location: At my coffee table

PostPosted: Fri May 09, 2008 5:11 pm
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
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: 2146
Location: At my coffee table

PostPosted: Fri May 09, 2008 5:19 pm
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

Senior Member


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

PostPosted: Fri May 09, 2008 6:02 pm
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
Reply with quote

I have the same doubts as CICS Guy
Back to top
View user's profile Send private message
CICS Guy

Senior Member


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

PostPosted: Fri May 09, 2008 6:13 pm
Reply with quote

FWIW, I noticed this a couple weeks back while researching in the PoOp for another topic question....
Under some circumstances, a zero with a minus sign (negative zero) is produced. For example, the multiplicand:
00 12 3D (-123)
times the multiplier:
0C (+0)
generates the product:
00 00 0D (-0)
because the product sign follows the algebraic rule of signs even when the value is zero. A negative zero, however, is equivalent to a positive zero in that they compare equal in a decimal comparison.
Back to top
View user's profile Send private message
birdy K

New User


Joined: 05 Mar 2008
Posts: 72
Location: chennai

PostPosted: Mon May 12, 2008 10:18 am
Reply with quote

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
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top