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

binary calculation


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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Nov 08, 2011 11:17 pm
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: 8797
Location: Welsh Wales

PostPosted: Tue Nov 08, 2011 11:21 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Nov 08, 2011 11:24 pm
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Tue Nov 08, 2011 11:47 pm
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: 8797
Location: Welsh Wales

PostPosted: Wed Nov 09, 2011 12:15 am
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

Active User


Joined: 20 May 2010
Posts: 121
Location: canada

PostPosted: Wed Nov 09, 2011 2:44 am
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Nov 09, 2011 3:02 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 09, 2011 4:23 am
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: 1353
Location: Israel

PostPosted: Thu Nov 10, 2011 3:18 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Allocated space calculation from DCOL... PL/I & Assembler 3
No new posts VSAM file Storage Calculation JCL & VSAM 3
No new posts Binary to display characters SYNCSORT 3
No new posts Check Binary Values for symbols CA Products 3
Search our Forums:

Back to Top