# Thread: convert interger value to binary value

1. Member
Join Date
Jan 2011
Posts
8
Rep Power
0

## convert interger value to binary value

hi '
i try to convert interger value to binary value using this code.
String by1 = Integer.toBinaryString(bulkpack.k);
this function return binary string value.

i need binary number and after i convert number to binary how i add these values and retun binary value.

2. Member
Join Date
Jan 2011
Posts
8
Rep Power
0

## Re

yes
the function binarytostring return binary value but in string form-

3. I'm confusing now with what you are saying.

That function returns the string representation of the binary number. Actually there is no binary type specifically.

4. As Eranga said, there is no binary type. There is however a byte type. But also, you can perform binary operations on other data types - shifts, XOR, OR, AND, etc... can all be applied to ints, longs, shorts, etc... So if you simply need to to binary ops, just use the binary ops syntax:
^ | >> >>> << and so forth.

If you are trying to visualize the steps, why not try printing the value of each int as you step through the process - for example:
Java Code:
```int a = 3;
int b = 7;
System.out.println("    "+Integer.toBinaryString(a));
System.out.println("    "+Integer.toBinaryString(b));
System.out.println("+ --------------------");
System.out.println("    "+Integer.toBinaryString(a|b));```
Here is the list of java operators, including bitwise ops:
Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

Good luck!
Last edited by quad64bit; 01-12-2011 at 02:50 PM.

5. Member
Join Date
Jan 2011
Posts
8
Rep Power
0

## solved

thanks for help

6. Please mark the thread solved then. It's easy to other members, specially for people who has the same issue as you.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•