Intellij长“整数值太大"但在 long.maxvalue 的范围内 [英] Intellij long "integer value is too big" but in range of long.maxvalue
本文介绍了Intellij长“整数值太大"但在 long.maxvalue 的范围内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能是一件愚蠢的事情,但是编译器怎么可能在 Long.Max = 9223372036854775807
时显示这个?
This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807
?
推荐答案
Java 中必须有 Long
字面量以 L
结尾,并添加 L
到您的整数将纠正您的问题,如下所示:Long s = 9223372036854775806L
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
这是因为默认情况下 Java 将所有整数解释为 32 位 (int
),后缀 L
确保您的整数被解释为 64 位.
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.
这篇关于Intellij长“整数值太大"但在 long.maxvalue 的范围内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文