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

我的梦境 提交于 2019-11-30 08:07:11

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

Java does support scientific notation:

3.30e23

You can try initializing a long variable and try casting it as a double/float. That may work but I'm not a 100%

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!