Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
aprak00
Warnings : 2

New User

Joined: 09 Aug 2006
Posts: 24

 Posted: Wed Mar 02, 2011 2:17 pm    Post subject: Convert COMP-1 and COMP-2 to readable format using REXX? 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.

enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10457
Location: italy

 Posted: Wed Mar 02, 2011 2:21 pm    Post subject: Reply to: Convert COMP-1 and COMP-2 to readable format using 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
prino

Senior Member

Joined: 07 Feb 2009
Posts: 1102
Location: Oostende, Belgium

Posted: Wed Mar 02, 2011 4:42 pm    Post subject:

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 */
aprak00
Warnings : 2

New User

Joined: 09 Aug 2006
Posts: 24

 Posted: Mon Mar 07, 2011 4:14 pm    Post subject: Thank you Prino...
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics GDG gen check using REXX raghuraman123 CLIST & REXX 6 Wed Apr 18, 2018 9:18 pm How to control Panel Attributes throu... rsshanmugam CLIST & REXX 3 Mon Feb 26, 2018 9:51 pm Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm how to get Job information from IOF u... rsshanmugam CLIST & REXX 13 Mon Feb 05, 2018 4:22 pm Unloading DB2 table in CSV format alo... grvtomar COBOL Programming 7 Sun Jan 28, 2018 2:05 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us