整数太大.错误,我该怎么办
我正在做一个返回两个长数的 GCD 的函数,当我尝试这个示例时,我收到此错误“整数太大”,尽管我尝试使用的数字太多小于长值的最大值
public class MyClass {
public static void main(String args[]) {
System.out.println(reduction(149361408, 37822859361));
}
static long reduction(long a, long b){
if(b==0) return a;
return reduction(b, a%b);
}
}
I am doing a function that return the GCD of two long number, and when I tried this example I get this error "integer number too large" although I tried with too number less than the max of long value
public class MyClass {
public static void main(String args[]) {
System.out.println(reduction(149361408, 37822859361));
}
static long reduction(long a, long b){
if(b==0) return a;
return reduction(b, a%b);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在数字中添加“L”,表示它是长整型
Add an "L" to the number so you indicate is a Long