I want to multiply for example; 0.1 * 10^30
How do I achieve this?
0.1 is a double 10^30 is a BigInteger
Human input will be converted into a double value but the value needs to be multiplied by 10^30 for computation.
Human input can be 0.09172349 for example.
Your best bet is to convert both to java.math.BigDecimal .
Please see the caveats and advice at the Javadoc for BigDecimal(double) . You mention "human input"; if you can take that human input directly as-is, and avoid bringing double
into the picture at all, then you should.
[…] the value needs to be multiplied by 10^30 for computation.
If you are always multiplying by 10 30 — that's a fixed constant — then you should use BigDecimal.movePointRight(int) .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.