Intellij long“整数值太大”但是在long.max值的范围内 [英] Intellij long "integer value is too big" but in range of long.maxvalue

查看:223
本文介绍了Intellij long“整数值太大”但是在long.max值的范围内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的事情,但是如何可能编译器将显示此时 Long.Max = 9223372036854775807

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

推荐答案

您必须在Java中以 L 结尾的 Long 文字,添加一个 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“整数值太大”但是在long.max值的范围内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆