Originally Posted by JosAH
|
Have a look at the Short or Integer classes; both can parse a String as if it were an integer number in (almost) any radix and they can produce a String representing a short (or int) in (almost) any radix; you have to get rid of the prefix 0b or 0x before the parsing but those prefixes tell you wich radix to use.
kind regards,
Jos
|
I believe he said he could not use the Integer class. Otherwise he could do something like this:
|
Code:
|
int i = Interger.parseInt("0110011011100110", 2); |
What he needs is a static field with powers of 2, and the charAt() method.