View previous topic :: View next topic
|
Author |
Message |
michaeltai Warnings : 1 New User
Joined: 23 Jul 2005 Posts: 20
|
|
|
|
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 |
|
|
michaeltai Warnings : 1 New User
Joined: 23 Jul 2005 Posts: 20
|
|
|
|
Anybody Help?! |
|
Back to top |
|
|
jayesh_g
New User
Joined: 03 Mar 2004 Posts: 23
|
|
|
|
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 |
|
|
michaeltai Warnings : 1 New User
Joined: 23 Jul 2005 Posts: 20
|
|
|
|
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 |
|
|
jayesh_g
New User
Joined: 03 Mar 2004 Posts: 23
|
|
Back to top |
|
|
michaeltai Warnings : 1 New User
Joined: 23 Jul 2005 Posts: 20
|
|
|
|
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 |
|
|
michaeltai Warnings : 1 New User
Joined: 23 Jul 2005 Posts: 20
|
|
|
|
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 |
|
|
sarma Kappagantu
New User
Joined: 17 Mar 2005 Posts: 22 Location: Bangalore
|
|
Back to top |
|
|
|