Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes

Author Message
anatol

Active User

Joined: 20 May 2010
Posts: 106

Posted: Tue Nov 08, 2011 11:17 pm    Post subject: binary calculation

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

expat

Global Moderator

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

 Posted: Tue Nov 08, 2011 11:21 pm    Post subject: 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.
anatol

Active User

Joined: 20 May 2010
Posts: 106

Posted: Tue Nov 08, 2011 11:24 pm    Post subject: Reply to: binary calculation

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         ***
anatol

Active User

Joined: 20 May 2010
Posts: 106

 Posted: Tue Nov 08, 2011 11:47 pm    Post subject: Reply to: binary calculation never mind , I found the problem - to big decimal value
expat

Global Moderator

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

 Posted: Wed Nov 09, 2011 12:15 am    Post subject: 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.
anatol

Active User

Joined: 20 May 2010
Posts: 106

Posted: Wed Nov 09, 2011 2:44 am    Post subject:

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)
enrico-sorichetti

Global Moderator

Joined: 14 Mar 2007
Posts: 10308
Location: italy

 Posted: Wed Nov 09, 2011 3:02 am    Post subject: Reply to: binary calculation so the conclusion is that there was a wrong understanding of the record layout
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Wed Nov 09, 2011 4:23 am    Post subject: Reply to: binary calculation 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?
Marso

REXX Moderator

Joined: 13 Mar 2006
Posts: 1243
Location: Israel

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

 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)
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Binary to display characters Roy Ware SYNCSORT 0 Tue Sep 19, 2017 8:46 pm Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am resume binary ftp in z/os meykh2014 All Other Mainframe Topics 6 Sun Jan 22, 2017 10:01 am Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm MSU calculation for DB2 (to decide be... SRICOBSAS DB2 4 Wed Mar 23, 2016 6:07 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us