除以大整数得到确切的价值 [英] Divide big integer number to get exact value
本文介绍了除以大整数得到确切的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想找到的值 1 /(2 ^ N),其中 0℃= N< = 200
我曾尝试使用的BigInteger,但它给输出为零。我想分割后确切的数字。
I have tried to use biginteger but it is giving output as zero . I want exact number after division .
import java.math.BigInteger;
public class Problem2 {
public static void main(String args[]){
BigInteger bi1 = new BigInteger("2").pow(200);
BigInteger bi2 = BigInteger.ONE;
BigInteger bi3 = bi2.divide(bi1);
System.out.println(bi3); //why it giving output zero
}
}
在使用BigDecimal的它给指数值,但如何获得准确的值,而指数。
On use of BigDecimal it is giving exponential value , but how to get exact value without exponent.
推荐答案
由于0℃ BI3和小于1,所以一个整数结果很到位的BigInteger
because 0< bi3 <1, so an integer result is 0. Try BigDecimal
in place of BigInteger
这篇关于除以大整数得到确切的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文