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

Author Message
Velkumar

New User

Joined: 23 Apr 2007
Posts: 18
Location: India

 Posted: Wed Aug 22, 2007 2:33 pm    Post subject: Convert a decimal number to Binary number I have a requirement where I need to convert a decimal number to Binary number. Then I will have to check the individual bits of the binary and findout if any bit is 'ON' to process further. Can anyone help me in converting a decimal number to Binary format. Can I store the converted bits into Alphanumeric variable?

dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

 Posted: Wed Aug 22, 2007 3:03 pm    Post subject: I suggest that you look at this website which provides examples of this kind of stuff. That should give you a starting point.
William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

 Posted: Wed Aug 22, 2007 3:14 pm    Post subject: 05 decimal-number pic s9(4). 05 binary-number pic s9(4) comp. 05 filler redefines binary-number. 10 filler pic x. 10 alphanumeric pic x. move decimal-number to binary-number. While the following will only get you the first bit, it should give you an idea: evaluate decimal-number when > 127 X'1nnnnnnn' when > 063 X'n1nnnnnn' when > 031 X'nn1nnnnn' when > 015 X'nnn1nnnn' when > 007 X'nnnn1nnn' when > 003 X'nnnnn1nn' when > 001 X'nnnnnn1n' when > 000 X'nnnnnnn1' end-evaluate
star_dhruv2000

New User

Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

Posted: Fri Aug 24, 2007 4:42 pm    Post subject:

It will be good if u Redefine a COMP variable onto your normal variable.

E.G.

 Code: 01A PIC 9(2). 01B PIC S9(4) COMP.

Now you can use B as individual bits
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Fri Aug 24, 2007 9:14 pm    Post subject:

Hello,

Quote:
It will be good if u Redefine a COMP variable onto your normal variable.

E.G.
 Code: 01A PIC 9(2). 01B PIC S9(4) COMP.

Now you can use B as individual bits

Please explain how you might use the individual bits of B. . . .

If you used a redefine (mentioned, but not shown in the code) and the value in A was 32 (x'F3F2'), the decimal "value" of B would be 62450. I'm not sure how either makes the individual bits "visable". I believe the bit settings for the 2 bytes would be "1111 0011 1111 0010".
dbzTHEdinosauer

Global Moderator

Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

Posted: Sat Aug 25, 2007 12:10 am    Post subject:

You could also check out the Language Environment Service: CEESITST, which is found in SA22-7562-03 z/OS V1R4.0 Language Environment Programming Reference
 Code: 2.3.4 CEESITST--Bit test        CEESITST selectively tests a bit in its parm1 input to determine if the bit is on.      ___ Syntax _____________________________________________________________    |                                                                        |   | >>__CEESITST__(__parm1__,__parm2__,__fc__,__result__)_______________>< |   |                                                                        |   |________________________________________________________________________|          parm1 (input)   The first input to the Bit Test routine. The input can be any 32-bit integer.     parm2 (input)   The second input to the Bit Test routine. The input is a 32-bit integer in the range 0 <= parm2 <= 31.     fc (output)   A 12-byte feedback code, optional in some languages, that indicates the result of this service.  The following symbolic conditions can result from this service:     result (output)   The result of the Bit Test routine. The output is a 32-bit integer with value:  1, if bit number parm2 in parm1 is 1 0, if bit number parm2 in parm1 is 0  Bits are counted from the righ
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Repeat Sequence Number Until change i... rahulabvp DFSORT/ICETOOL 6 Thu Mar 29, 2018 12:51 pm How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm PARSE GDG name to separate generation... Abid Hasan SYNCSORT 2 Sun Feb 11, 2018 3:40 pm Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm

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