Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula Help

Status
Not open for further replies.

priyanthan

Programmer
Jul 27, 2008
70
CA
Can any one please tell me how to convert int into Binary.
for example;
i need to change 2 into 0010
3 into 0011
4 into 0100
5 into 0101

and then "AND" the 0010 and 0011.
for example;
0010 AND 0011 should give me 0010.

working with CR 8.5 and DB2.

Can anyone tell me how to do this.

Thanks in advance.
 
I believe two steps are involved here. First, converting numbers into binary (If you have a limited range, then it might be easier to a select case statement (select {decimal number} case 1 : "0001" case 2 : "0010", etc., not sure on the syntax).

Second, once you have two binary numbers, then I think you would have to use a 'for loop' to do a 'AND' on each of the four positions, and build a new string from that.

I have not tried doing this yet.

Lots of luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top