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-1 and comp-2 values

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Jul 20, 2010 10:57 am    Post subject: comp-1 and comp-2 values
Reply with quote

Hi

The PIC clause for comp-1 and comp-2 are :

COMP-1 : SV9(8)ES99

COMP-2: SV9(17)ES99

I want to know how 'S' is represented in the exponential part ( ES99) . Under what scenario will it show negative ( - ) ? Or will it be +ve always (i.e.blanks).

I mean will it ever show something like ( -.12300000E-03) , for an input say -123 moved to comp-1 and comp-2 ?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 20, 2010 1:20 pm    Post subject:
Reply with quote

Internal representation
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Jul 20, 2010 1:58 pm    Post subject:
Reply with quote

I had seen this link earlier also,but couldn't figure out how the comp-1 internal representation came to 43 4D 20 00 for +1234.

could you please help me with it ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 20, 2010 4:34 pm    Post subject:
Reply with quote

well, you need to start at basics.

floating-point

COMP-1 and COMP-2 are internal-floating point. They do not have picture clauses

discussions on external floating point are referenced in the above link.

Quote:
could you please help me with it ?


you need to spend some time reading the manual.
I am not going to paraphrase it for you.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Jul 21, 2010 10:34 am    Post subject: Reply to: comp-1 and comp-2 values
Reply with quote

Hi

Thanks for the links . I did go through them and it helped me.

I could understand the internal representation of value +1234 in binary is 04 D2 . But i couldn't figure out how the represenation for -1234 would be determined ?

Could you please help.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Wed Jul 21, 2010 3:56 pm    Post subject:
Reply with quote

Hex C3 4D 20 00 -- the sign bit is turned on to denote the negative value. The 43 4D 20 00 remains exactly the same.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Jul 22, 2010 8:49 am    Post subject: Reply to: comp-1 and comp-2 values
Reply with quote

This is were i am confused.

For Binary , value of +1234 has internal representation as 04 D2 , coz the binary value would be 0000 0100 1101 0010.

But for value -1234 how is it FB 2E.

Secondly for same value in Comp-1 how is it represented as 43 4D 20 00 ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jul 22, 2010 9:14 am    Post subject:
Reply with quote

Hello,

Quote:
But for value -1234 how is it FB 2E.
Because FB2E is the result when 4D2 is subtracted from zero. . .

You can verify this (and do other similar experiments) using the hex calculator on your pc.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Jul 22, 2010 1:37 pm    Post subject:
Reply with quote

ya i understood now how -1234 is FB2E , but couldn't understand how the Comp-1 representation is 43 4D 20 00
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Thu Jul 22, 2010 5:00 pm    Post subject:
Reply with quote

Since you obviously have a reading problem (this is explained in the COBOL manuals as you have been repeatedly told), I'll elaborate:

The first bit is the sign bit -- 0 means positive, 1 means negative.

The next seven bits are the exponent. For technical reasons, IBM stores the exponent in excess-64 notation (meaning they add 64 or hex 40 to the actual exponent). Hence 43 minus 40 is 3 (even in hex), so the exponent is 3.

The remaining 24 bits represent the mantissa of the floating point number. So the 4D2000 represents the 1234. The decimal point is implied after the first digit -- as IBM explicitly states in the manual.

So positive 1.234 times 10 raised to the third power is ... 1234.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Jul 23, 2010 11:12 am    Post subject:
Reply with quote

Thanks Robert for the explanantion.

You said this is explained in the COBOL manuals ,

Could you please let me know which COBOL manual should be referred.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Sep 28, 2010 6:59 pm    Post subject:
Reply with quote

Hi Robert ,

In your above reply you have mentioned For technical reasons, IBM stores the exponent in excess-64 notation (meaning they add 64 or hex 40 to the actual exponent). Hence 43 minus 40 is 3 (even in hex), so the exponent is 3.


Could you please explain how 43 is obtained ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7913
Location: Bellevue, IA

PostPosted: Tue Sep 28, 2010 7:25 pm    Post subject:
Reply with quote

Start with the value. Shift the decimal point left or right until the decimal point is behind the first digit. The number of shifts is the exponent value. If you shifted left, the value is positive. If you shifted right, the value is negative.

1234 requires 3 shifts to be 1.234, hence the 3 -- and since the shifts were to the left, it is a positive three.

.0012345 requires 3 shifts to be 1.234, so again a 3 -- but this time the shifts were to the right, so the value is negative 3.

IBM adds the 40 (hex) automatically -- so +3 added to 40 becomes 43. 40 hex minus 3 is 3D so .001234 expressed as a COMP-1 value is 3D 4D 20 00
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Sep 29, 2010 11:12 am    Post subject:
Reply with quote

That was really helpful Robert.Thanks a lot icon_razz.gif
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
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
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 Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


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