How to express numbers with scientific symbols in Java?
•
Java
There is already an answer to this question: > 5 format double value in scientific notation
3.30 x 10ˆ23
One element in my planetary group will be:
33.0 * Math.pow(10,23)
However, I don't think this is the right way - it seems to throw an exception... So how can I express a large number of numbers from the programmer's point of view? thank you!
Solution
Section 3.10. 2 of the JLS on floating point text in Java In short, provide the decimal part as if it were a scientific symbol, not x 10 ^ 23. You would write E23:
3.30e23
To write a negative index, you can easily do 6.67 x 10 ^ (– 11):
6.67e−11
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码