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
 

 

Help me about the internal representation of COMP-2 format

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

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Sat Aug 06, 2005 7:04 pm    Post subject: Help me about the internal representation of COMP-2 format
Reply with quote

According to IBM?s manual, the decimal value +1234 should be represented as below

Part 1? 1 digit , sign
Part 2? 7 digits, exponent
Part 3? 7 bytes, mantissa

+1234 = +1.234E3 , so I think the exponent( Part 2) should be 0000011 instead of 1000011
Besides, I am not quite clear about Part 3, the mantissa for this case should be 1.234, why it is represented here as 4D20 00 00 00 00 00
Back to top
View user's profile Send private message

michaeltai
Warnings : 1

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Tue Aug 09, 2005 7:12 pm    Post subject:
Reply with quote

Anybody Help?!
Back to top
View user's profile Send private message
jayesh_g

New User


Joined: 03 Mar 2004
Posts: 24

PostPosted: Thu Aug 11, 2005 11:53 pm    Post subject: Re: Help me about the internal representation of COMP-2 form
Reply with quote

Which is the IBM manual that you are referring to?

What you have shown seems to be internal floating point representation of the number +1234.

The exponent is stored in what is called as "excess-N" notation. X'4D2' is your number. The zeroes at the end of the mantissa is to correct the precision.

For more information on floating point arithmetic, go to http://grouper.ieee.org/groups/754/

-Jayesh.
Back to top
View user's profile Send private message
michaeltai
Warnings : 1

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Fri Aug 12, 2005 5:29 pm    Post subject: Re: Help me about the internal representation of COMP-2 form
Reply with quote

The IBM manual I am referring to is Enterprise COBOL for Z/OS Programming Guide.

It is described as below:
COMP-1 refers to short floating-point format and COMP-2 refers to long floating-point format, which occupy 4 and 8 bytes of storage, respectively. The leftmost bit contains the sign and the next 7 bits contain the exponent; the remaining 3 or 7 bytes contain the mantissa.

+1234 = 1.234E3 so it's exponent (part 2) should be 3 ,that is 0000011 in binary. But the example shows 1000011 that is 67 in decimal. I am so confused about this.

In addition, you've mentioned that the zeros behind 4D2(1234) is to correct the precision of the mantissa, could you explain to me how this mechanism works. Thanks in advance.
Back to top
View user's profile Send private message
jayesh_g

New User


Joined: 03 Mar 2004
Posts: 24

PostPosted: Sat Aug 13, 2005 12:17 am    Post subject: Re: Help me about the internal representation of COMP-2 form
Reply with quote

Let us learn mathematics. Check out this link: http://stevehollasch.com/cgindex/coding/ieeefloat.html

-Jayesh.
Back to top
View user's profile Send private message
michaeltai
Warnings : 1

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Sat Aug 13, 2005 6:57 am    Post subject:
Reply with quote

According to the standards you provide, the actual exponent here is 3, as for this double precision comp-2 ,1023 should be added, and 1026 will become the ultimate stored exponent and it will occupy 11 bits (10000000010) that's quite different from the example. I'm wondering whether or not IBM conforms to IEEE standards.
Back to top
View user's profile Send private message
michaeltai
Warnings : 1

New User


Joined: 23 Jul 2005
Posts: 20

PostPosted: Wed Aug 17, 2005 2:21 pm    Post subject: Re: Help me about the internal representation of COMP-2 form
Reply with quote

Today, I've tried out several other numbers, and very confused about the mantissa part.

C4200000 -1.234E+3
3D000000

44200000 +1.234E+3
3D000000

47666666 +1.234E+2
2B666666

4C7AD037 +1.234E+1
15037AD1

41B7CB35 +1.234E0
13E68498

4192758F +1.234E-1
0F7443E3

33868E1E +1.234E-2
F2BD6C7C

35D1AAF1 +1.234E-3
E0F54C33
Back to top
View user's profile Send private message
sarma Kappagantu

New User


Joined: 17 Mar 2005
Posts: 22
Location: Bangalore

PostPosted: Mon Jan 16, 2006 8:54 am    Post subject: Re: Help me about the internal representation of COMP-2 form
Reply with quote

Pl find an explanation here @ http://www.tek-tips.com/faqs.cfm?fid=5154

Regards,
Sarma.
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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
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 output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm


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