View previous topic :: :: View next topic

Author 
Message 
Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




Hi
The PIC clause for comp1 and comp2 are :
COMP1 : SV9(8)ES99
COMP2: 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 ( .12300000E03) , for an input say 123 moved to comp1 and comp2 ? 

Back to top 




dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne


Back to top 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




I had seen this link earlier also,but couldn't figure out how the comp1 internal representation came to 43 4D 20 00 for +1234.
could you please help me with it ? 

Back to top 


dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne




well, you need to start at basics.
floatingpoint
COMP1 and COMP2 are internalfloating 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 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




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 


Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8201 Location: Dubuque, Iowa, USA




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 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




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 Comp1 how is it represented as 43 4D 20 00 ? 

Back to top 


dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix




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 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




ya i understood now how 1234 is FB2E , but couldn't understand how the Comp1 representation is 43 4D 20 00 

Back to top 


Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8201 Location: Dubuque, Iowa, USA




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 excess64 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 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




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 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




Hi Robert ,
In your above reply you have mentioned For technical reasons, IBM stores the exponent in excess64 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 


Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8201 Location: Dubuque, Iowa, USA




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 COMP1 value is 3D 4D 20 00 

Back to top 


Ambili S
Active User
Joined: 06 Sep 2007 Posts: 112 Location: India




That was really helpful Robert.Thanks a lot 

Back to top 


