how to convert binary string to int?
I need to know how you convert a binary string into its integer variable type equivelant.
String s="1001" (which is actually the number 9 in binary base 2)
I want to know how to convert it into an int or long variable type.
Is there a method that will take the binary string ie. "Integer.convertBinaryString()" that will take my binary string and convert it into the Base 10 integer equivelant?
Ive heard of the Integer.Decode() method, but I think it only works for converting base 8 and base 16 strings into the integer equivelant. I dont think it converts base 2 strings into int. Does anyone know how to convert a base 2 number in string form into the base 10 integer equivelant?
String binaryString = "1001";
int base = 2;
int decimal = Integer.parseInt(binaryString, base);
hey, thanx alot man.
I must have some how over looked it in the java API docs if it was there.
They call the base "the radix" in the API docs.
Originally Posted by bob2000
Prometheuzz.... I thik U cn help me vid my problem.. I have an array of String type...
each index is storing a 32-bit binary String...
I wish to convert it into an Integer array.. I have to use these integer values as pixel values and create an image using these.. M Badly Stuck Up... A binary String like "00001111" when converted to integer returns just "1111" .. How can I conserve these zero's...
as of now I have used both the above mentioned statements.. guide me thru...
By chintucs in forum Java
Last Post: 01-21-2007, 05:08 PM
By lordanki in forum Java
Last Post: 04-04-2006, 11:13 AM
Last Post: 10-03-2005, 12:57 AM
Last Post: 07-04-2001, 06:18 AM
By Kunal Sharma in forum VB Classic
Last Post: 04-25-2000, 04:45 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center