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

Author Message
Shah

New User

Joined: 05 Sep 2006
Posts: 18

 Posted: Sat Dec 16, 2006 7:15 pm    Post subject: Convert given decimal number into Binary Hi all, How can we Convert given decimal number into Binary? Thanks, Shah

dick scherrer

Site Director

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

 Posted: Tue Dec 26, 2006 9:57 pm    Post subject: Hello, Try 05 flda pic s9(7) comp-3. 05 fldb pic s9(7) comp. COMPUTE FLDA = (whatever * 3). MOVE FLDA to FLDB. At this point, flda and fldb will contain the same numeric value - flda stored in packed decimal and fldb stored in binary.
Shah

New User

Joined: 05 Sep 2006
Posts: 18

 Posted: Wed Jan 03, 2007 6:08 pm    Post subject: Re: Convert given decimal number into Binary dick scherrer, Could you please give the code in NATURAL language. Thanks, Shaik
dick scherrer

Site Director

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

 Posted: Wed Jan 03, 2007 9:00 pm    Post subject: Hi Shaik, My current "inventory" doesn't include NATURAL. I'd suggest looking in the NATURAL referance documentation for syntax - in the section on "working data" or "defining elementary fields" or something similar. You might also check on how numeric fields are defined in ADABAS. Your NATURAL programs can both read and write various numeric formats. Sorry that i can't be more help.
ofer71

Global Moderator

Joined: 27 Dec 2005
Posts: 2360
Location: Israel

Posted: Thu Jan 04, 2007 1:47 am    Post subject:

Shah -

Here is something I wrote few minutes ago. It is not perfect, but you'll get the idea.
 Code: DEFINE DATA LOCAL                                      1 #DECIMAL (N4)                                        1 #BINARY  (N23)                                        1 REDEFINE #BINARY                                        2 #BIN   (N1/23)                                      1 #I       (I2) INIT <23>                              1 #J       (I2) INIT <0>                                1 #RES     (N4)                                        END-DEFINE                                              *                                                      COMPUTE #DECIMAL = 5555                                *                                                      REPEAT UNTIL #DECIMAL LE 1                                DIVIDE 2 INTO #DECIMAL GIVING #RES REMAINDER #BIN(#I)   COMPUTE #DECIMAL = #DECIMAL / 2                        COMPUTE #I = #I - 1                                  END-REPEAT                                              *                                                      COMPUTE #BIN(#I) = #DECIMAL                            *                                                      DISPLAY #BINARY                                        END

O.
Shah

New User

Joined: 05 Sep 2006
Posts: 18

 Posted: Thu Jan 04, 2007 2:29 pm    Post subject: Re: Convert given decimal number into Binary Ofer71, Thanks for giving code. I will try that and let you know. Thank u very much, Shah
Shah

New User

Joined: 05 Sep 2006
Posts: 18

 Posted: Thu Jan 04, 2007 2:57 pm    Post subject: Re: Convert given decimal number into Binary Ofer71, Just now i tried with that code, That's great, its working exactly. But i need some clarifications (because iam just stepping into NATURAL recently). 1. Why you consider #BINARY as (N23) , is there any reason. 2. Redefined #BINARY as #BIN with (N1/23)? What it its meaning. Please clarify if you have time. Thanks in advance, Shah
ofer71

Global Moderator

Joined: 27 Dec 2005
Posts: 2360
Location: Israel

 Posted: Thu Jan 04, 2007 4:06 pm    Post subject: Shah - The "23" is just a number. You may change it to whatever suitable for you. Same for the #BIN array. It is used to place the bits under #BINARY. O.
Shah

New User

Joined: 05 Sep 2006
Posts: 18

 Posted: Thu Jan 04, 2007 4:50 pm    Post subject: Re: Convert given decimal number into Binary Thanks Ofer71, Regards, Shaik
 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