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

Help me about the internal representation of COMP-2 format


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
Reply with quote

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

New User


Joined: 03 Mar 2004
Posts: 23

PostPosted: Thu Aug 11, 2005 11:53 pm
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
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: 23

PostPosted: Sat Aug 13, 2005 12:17 am
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
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
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
Reply with quote

Pl find an explanation here @ 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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top