问题
I want to divide two large integers,
a = 23546654
b = 24979799
and to get the result in double.
回答1:
Try
double x = ((double) a) / ((double) b)
which first converts your ints to doubles and then does the division. If you have BigInteger
s (which your tag indicates) you may use BigInteger.doubleValue() to extract the double value.
回答2:
This are plain int
rather than BigInteger.
All you need is
double ratio = (double) a / b;
回答3:
BigInteger class has a divide
method.
BigInteger result = a.divide(b);
来源:https://stackoverflow.com/questions/8727587/how-to-divide-two-large-integers-in-java