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

Convert COMP-1 and COMP-2 to readable format using REXX?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aprak00
Warnings : 2

New User


Joined: 09 Aug 2006
Posts: 24

PostPosted: Wed Mar 02, 2011 2:17 pm
Reply with quote

Could anyone please let me know how to convert COMP-1 and COMP-2 to readable format using REXX? I am able to convert Binary and Packed decimals to readable format.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Mar 02, 2011 2:21 pm
Reply with quote

when asking REXX questions refrain from using COBOLESE,
if You use COBOLESE You will limit the number of people able to reply,
not all the people proficient in REXX use that other language..

but... if instead of asking You had done a bit of homework You would have found this
www.connelley.org/Coding_Examples/c2f.html
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Mar 02, 2011 4:42 pm
Reply with quote

Or this, if you need extended floating points (no clue as to what they are in the COBOL world...):

Code:
/* This REXX exec computes a S/370 floating-point's value ...
   e.g. X'C1280000' represents -2.5
                                  (Michel Castelein, 5 November 1997)*/
say 'Enter the S/370 floating-point (4, 8, or 16 bytes):'
numeric digits 34
pull float

float = X2C(float)           /* convert float to a hexadecimal string*/
float_size = LENGTH(float)                           /* size in Bytes*/

Byte_0 = SUBSTR(float, 1, 1)
select
  when BITAND(Byte_0, '80'x) == '00'x then sign = '+'
  when BITAND(Byte_0, '80'x) == '80'x then sign = '-'
end

exponent = C2D(BITAND(Byte_0, '7F'x)) - 64
fraction = 0
power    = -1

do i = 2 to float_size
   if i = 9 then iterate                           /* skip bits 64-71*/
   Next_Byte   = C2D(SUBSTR(float, i, 1))
   left_Digit  = Next_Byte % 16
   fraction    = fraction + left_Digit * 16**power
   right_Digit = Next_Byte // 16
   power       = power - 1
   fraction    = fraction + right_Digit * 16**power
   power       = power - 1
end
interpret 'value =' sign ( fraction * 16 ** exponent )
say "The floating-point's value is" value
say
say 'Press Enter to continue'
pull
return
/*
TEST_WORK.FS=1.00000E+01;
TEST_WORK.FL=1.000000000000000E+01;
TEST_WORK.FE=1.00000000000000000000000000000000E+01;
'41A00000'B
'41A0000000000000'B
'41A00000000000003300000000000000'B
TEST_WORK.FS=3.16227E+00;
             3.16227722167968750000
TEST_WORK.FL=3.162277660168379E+00;
             3.162277660168379300742458326567430049181
TEST_WORK.FE=3.16227766016837933199889354443270E+00;
             3.162277660168379331998893544432716995013
'413298B0'B
'413298B075B4B6A5'B
'413298B075B4B6A533240945790619B3'B
*/
Back to top
View user's profile Send private message
aprak00
Warnings : 2

New User


Joined: 09 Aug 2006
Posts: 24

PostPosted: Mon Mar 07, 2011 4:14 pm
Reply with quote

Thank you Prino...
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top