Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Tue Jul 20, 2010 10:57 am    Post subject: comp-1 and comp-2 values 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 ?

dbzTHEdinosauer

Global Moderator

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

 Posted: Tue Jul 20, 2010 1:20 pm    Post subject: Internal representation
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Tue Jul 20, 2010 1:58 pm    Post subject: 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 ?
dbzTHEdinosauer

Global Moderator

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

Posted: Tue Jul 20, 2010 4:34 pm    Post subject:

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.

you need to spend some time reading the manual.
I am not going to paraphrase it for you.
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Wed Jul 21, 2010 10:34 am    Post subject: Reply to: comp-1 and comp-2 values 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.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8201
Location: Dubuque, Iowa, USA

 Posted: Wed Jul 21, 2010 3:56 pm    Post subject: 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.
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Thu Jul 22, 2010 8:49 am    Post subject: Reply to: comp-1 and comp-2 values 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 ?
dick scherrer

Site Director

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

Posted: Thu Jul 22, 2010 9:14 am    Post subject:

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.
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Thu Jul 22, 2010 1:37 pm    Post subject: ya i understood now how -1234 is FB2E , but couldn't understand how the Comp-1 representation is 43 4D 20 00
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8201
Location: Dubuque, Iowa, USA

 Posted: Thu Jul 22, 2010 5:00 pm    Post subject: 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.
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Fri Jul 23, 2010 11:12 am    Post subject: 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.
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Tue Sep 28, 2010 6:59 pm    Post subject: 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 ?
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8201
Location: Dubuque, Iowa, USA

 Posted: Tue Sep 28, 2010 7:25 pm    Post subject: 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
Ambili S

Active User

Joined: 06 Sep 2007
Posts: 112
Location: India

 Posted: Wed Sep 29, 2010 11:12 am    Post subject: That was really helpful Robert.Thanks a lot
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us