dcsimg

How do I initialize an int from a string of binary digits?

John Zukowski

To go from something like "0101010101" to the int equivalent, use the Integer.parseInt(binaryString, 2) method. If you prefer to go to an Integer, instead of an int, use Integer.valueOf(binaryString, 2) instead. The 2 represents the radix, or base of the number.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.