3

I have following problem:

I want to convert some Binary Strings to an integer:

eargb = Integer.parseInt(al + re + gre + blu, 2);

but I get following exception. Why?

java.lang.NumberFormatException: For input string: "11111111111000101000100111111010"

4 Answers 4

8

Your number (4,293,036,538) is too large to fit in a signed int (which has a range of -2,147,483,648 to 2,147,483,647).

Try using a long instead. This has a larger range.

Sign up to request clarification or add additional context in comments.

Comments

3

How about

long eargb = Long.parseLong(al + re + gre + blu, 2);

Comments

1

Your binary number exceeded Integer size. Thats why your getting this exception

Comments

0

It has been 7 months but the target answer has not been described. Also this question is leading in search engines. The above mentioned subjects are true. You should use as follow:

(int)Long.parseLong("11111111111000101000100111111010",2)

eargb =(int)Long.parseLong( al + re + gre + blu, 2);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.