How to express numbers in scientific notation in java? [duplicate]

Section 3.10.2 of the JLS talks about floating-point literals in Java. In short, provide the decimal part as if it were scientific notation, but instead of x 10^23 you would write e23:

3.30e23

To write one with a negative exponent, you can do that easily also for 6.67 x 10^(-11):

6.67e−11

Leave a Comment