如果条件不执行大数字.为什么?代码有什么问题? [英] if condition not executing for big numbers.why? whats wrong in the code?

查看:72
本文介绍了如果条件不执行大数字.为什么?代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for(int i=0;i<=f;i++)
	
{
    BigInteger ib=BigInteger.valueOf((long)i);
    //BigInteger r=  g1.Power(i);
    //System.out.println("g^ib =" +r);
    BigInteger s= g1.modPow(ib,p1);
    //System.out.println("r:" +r);

    //System.out.println("a" +a1);
    //System.out.println("p" +p1);
    //System.out.println("s:" +s);
    //System.out.println("a1:" +a1);
    //BigInteger a1 = BigInteger.valueOf((long)a);

    if(s.equals(a1))
    {
        System.out.println("The value of m is : \t" +i);
    }
    break;
}
//else
// System.out.print("the value did not match \n");

}

推荐答案

因为您已经注释了定义a1 ...
Because you''ve commented out the line that defines a1...


的行a1BigInteger吗?如果是这样,比较将起作用; 参阅Java文档 [ ^ ].
Is a1 a BigInteger? If so, the comparison will work; see the Java Doc[^].


它与注释行无关.我已经在之前的代码中声明了a1,并且尝试在for循环中使用它,但这没有用.
不检查条件是否包含大整数.
如果我给小的输入数字,它可以正确执行.
its not about the comment line . i have already declared a1 in the previous code and i have tried using it in the for loop but it is of no use.
the condition is not checked for big integers.
if i give small input numbers its executing correctly.


这篇关于如果条件不执行大数字.为什么?代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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