Java 整数 parseInt 错误
我有以下问题:
我想将一些二进制字符串转换为整数:
eargb = Integer.parseInt(al + re + gre + blu, 2);
但出现以下异常。为什么?
java.lang.NumberFormatException: For input string: "11111111111000101000100111111010"
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"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的数字(4,293,036,538)太大,无法放入有符号整数(其范围为-2,147,483,648到2,147,483,647)。
尝试使用 long 代替。这个范围比较大。
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.
怎么样
How about
您的二进制数超出了整数大小。这就是为什么你会得到这个异常
Your binary number exceeded Integer size. Thats why your getting this exception
已经7个月了,但目标答案还没有描述。这个问题也在搜索引擎中处于领先地位。上述主题均属实。您应该按如下方式使用:
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: