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
 

 

Convert given decimal number into Binary

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
Shah

New User


Joined: 05 Sep 2006
Posts: 18

PostPosted: Sat Dec 16, 2006 7:15 pm    Post subject: Convert given decimal number into Binary
Reply with quote

Hi all,

How can we Convert given decimal number into Binary?

Thanks,
Shah
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Tue Dec 26, 2006 9:57 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Shah

New User


Joined: 05 Sep 2006
Posts: 18

PostPosted: Wed Jan 03, 2007 6:08 pm    Post subject: Re: Convert given decimal number into Binary
Reply with quote

dick scherrer,

Could you please give the code in NATURAL language.

Thanks,
Shaik
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Jan 03, 2007 9:00 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Jan 04, 2007 1:47 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Shah

New User


Joined: 05 Sep 2006
Posts: 18

PostPosted: Thu Jan 04, 2007 2:29 pm    Post subject: Re: Convert given decimal number into Binary
Reply with quote

Ofer71,

Thanks for giving code. I will try that and let you know.

Thank u very much,
Shah
Back to top
View user's profile Send private message
Shah

New User


Joined: 05 Sep 2006
Posts: 18

PostPosted: Thu Jan 04, 2007 2:57 pm    Post subject: Re: Convert given decimal number into Binary
Reply with quote

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
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Jan 04, 2007 4:06 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Shah

New User


Joined: 05 Sep 2006
Posts: 18

PostPosted: Thu Jan 04, 2007 4:50 pm    Post subject: Re: Convert given decimal number into Binary
Reply with quote

Thanks Ofer71,

Regards,
Shaik
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 -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts resume binary ftp in z/os meykh2014 All Other Mainframe Topics 6 Sun Jan 22, 2017 10:01 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am


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