Converting 32-bit binary string with Integer.parseInt fails

前端 未结 4 729
慢半拍i
慢半拍i 2020-12-07 01:14

Why does this part of code fail:

Integer.parseInt(\"11000000000000000000000000000000\",2);

Exception in thread \"main\" java.lang.NumberFormatException: For         


        
4条回答
  •  执念已碎
    2020-12-07 01:48

    According to the docs, the max value of an Integer is 2^31-1. Which, in binary is:

    1111111111111111111111111111111

    In other words, 31 1's in a row.

提交回复
热议问题