初始化长号

时间:2013-01-23 10:22:46

标签: java long-integer

我正在开发一个我想要的硬件接口应用程序 按任意long号码初始化8 byte数据类型值(因为它已修复) dll文件中给出的键示例:

long fixedKey=0123456701234567; //error on this line

Error is : The literal 0123456701234567 of type int is out of range 

我见过long的原始数据类型( Java API )范围来自 -9,223,372,036,854,775,808至9,223,372,036,854,775,807 (19位数字)。       显然我输入的号码(16位数字)在 long数据类型的范围,为什么我会收到这种错误。

3 个答案:

答案 0 :(得分:12)

L追加到最后,使其成为long literal

long fixedKey=0123456701234567L; //error on this line

答案 1 :(得分:1)

您应该为您的号码添加L后缀。另外,您确定要以八进制表示您的号码吗?

答案 2 :(得分:1)

使用L表示它是类似

的长类型
long fixedKey=0123456701234567L;