Unexpected int/Integer behavior when number starts by 0

北战南征 提交于 2019-12-06 13:18:56

Adding 0 to the front made the number an Octal literal. So:

0400300 = 3 * 8 ^ 2 + 4 * 8 ^ 5 = 131264

See JLS for the relevant sections. Quote:

An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII digits 0 through 7 interspersed with underscores, and can represent a positive, zero, or negative integer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!