Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Convert COMP-1 and COMP-2 to readable format using REXX?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Convert COMP-1 and COMP-2 to readable format using REXX?
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10396
Location: italy

PostPosted: Wed Mar 02, 2011 2:21 pm    Post subject: Reply to: Convert COMP-1 and COMP-2 to readable format using
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
http://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: 1074
Location: Oostende, Belgium

PostPosted: Wed Mar 02, 2011 4:42 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am
No new posts Can we create REXX ouput in an Excel ... upendrasri CLIST & REXX 3 Wed Jan 17, 2018 8:19 pm
No new posts Need to obtain VTOC information via R... djeffbland CLIST & REXX 10 Thu Jan 11, 2018 4:13 am
No new posts REXX contest sergeyken CLIST & REXX 2 Tue Jan 09, 2018 1:55 am
No new posts Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us