Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function for binary string to decimal

Tags:

java

binary

I have converted a decimal number to binary using

int k=8;
String toBinaryString = Integer.toBinaryString(k);

After some manipulation I want the int value back. Can anyone help me with the function or do I have to convert it using loops only.

like image 253
harry4 Avatar asked Feb 18 '26 21:02

harry4


1 Answers

You can use:

int originalValue = Integer.parseInt(toBinaryString , 2));
like image 111
Reimeus Avatar answered Feb 21 '26 12:02

Reimeus