Intellij long “integer value is too big” but in range of long.maxvalue

走远了吗. 提交于 2019-12-08 17:43:53

问题


This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807 ?


回答1:


You must have Long literals in Java ending with an L, adding an L to your integer will correct your issue, like so: Long s = 9223372036854775806L

This is because by default Java interprets all integers as 32-bit (int), the suffix L ensures that your integer is interpreted as 64-bit.




回答2:


just put 'l' or 'L' in the end of it and it will be ok, like:

long a = 9223372036854775807L;



回答3:


Use Long s = 9223372036854775806L



来源:https://stackoverflow.com/questions/28305327/intellij-long-integer-value-is-too-big-but-in-range-of-long-maxvalue

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