Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

binary calculation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Nov 08, 2011 11:17 pm    Post subject: binary calculation
Reply with quote

I have record in a file :
Code:
 ---------------
........ISH01P 
00000000CECFFD44
0101000192801700
 ---------------


I can read and substr '0001000100000001'x to the variable. But I cannot build the folowing record :
Code:
 ---------------
........ISH01P 
00000000CECFFD44
0101000292801700
 ---------------


just add '1'x to the value in 8 first position in the file
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Tue Nov 08, 2011 11:21 pm    Post subject:
Reply with quote

Oh well, never mind. How about posting something useful for us to consider.

Your code would be a good start. Along with an exact description of what you want to achieve.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Nov 08, 2011 11:24 pm    Post subject: Reply to: binary calculation
Reply with quote

ok, hard to explaine...

if i read the record , how can I increment by 1 the hex value in first 8 positions..
Code:
   "EXECIO * DISKR SSS1 (FINIS STEM LF1."     
   "FREE FI(SSS1)"                             
   IC = LF1.0                                 
  COUNT = C2X(SUBSTR(LF1.IC,1,8))   
  SAY COUNT                                   
  COUNT = COUNT + 1                           
  SAY COUNT                                   
  EXIT                                         


result
Code:
 '000100010000000E'                                             
     22 +++ COUNT = COUNT + 1                                   
 Error running MERGISS, line 22: Bad arithmetic conversion       
 ***                                                             
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Tue Nov 08, 2011 11:47 pm    Post subject: Reply to: binary calculation
Reply with quote

never mind , I found the problem - to big decimal value
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Nov 09, 2011 12:15 am    Post subject:
Reply with quote

Well done for finding the solution,

And another big one for posting what the problem was.

I assume that you used the NUMERIC DIGITS nn to resolve this.
Back to top
View user's profile Send private message
anatol

New User


Joined: 20 May 2010
Posts: 99
Location: canada

PostPosted: Wed Nov 09, 2011 2:44 am    Post subject:
Reply with quote

just used less positions... not 8 ... 4
Code:

                                         
 IC = LF1.0                                                 
 COUNT = C2D(SUBSTR(LF1.IC,5,4))                             
                                                             
                   
 COUNT = COUNT + 1                                           
 COUNT1= RIGHT(D2X(COUNT),8,0)                               
 LF1.IC =SUBSTR(LF2.I,1,4)||X2C(COUNT1)||SUBSTR(LF2.I,9)     
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Wed Nov 09, 2011 3:02 am    Post subject: Reply to: binary calculation
Reply with quote

so the conclusion is that there was a wrong understanding of the record layout
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Nov 09, 2011 4:23 am    Post subject: Reply to: binary calculation
Reply with quote

What happens on the one chance in you all the combinations that you actually get a "carry"?

With decimals, you solution would work with aaaaxxxx, where aaaa is anything and xxxx is 9999?

What if your eight bytes is -ve, but the rightmost four look positive, or vice versa?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Thu Nov 10, 2011 3:18 pm    Post subject: Re: Reply to: binary calculation
Reply with quote

anatol wrote:
never mind , I found the problem - to big decimal value

You forgot to say that you changed the C2X to C2D, then you got the too big decimal value...

anatol wrote:
COUNT1= RIGHT(D2X(COUNT),8,0)
LF1.IC =SUBSTR(LF2.I,1,4)||X2C(COUNT1)||SUBSTR(LF2.I,9)

I would have used:
Code:
Count1 = D2C(Count,4)               
LF2.IC = Overlay(Count1,LF1.IC,5,4)
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 Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm
No new posts MOVING COMP-3 into binary akodakka COBOL Programming 2 Tue Dec 01, 2015 5:02 pm
No new posts USS Shell script:Convert hex to binar... RSR2015 All Other Mainframe Topics 0 Fri Sep 18, 2015 2:00 am
No new posts extract records based on Binary field chockalingam_rsp SYNCSORT 34 Fri May 01, 2015 2:23 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us