如何在Java中将字符串3.0103E

编程入门 行业动态 更新时间:2024-10-22 10:40:57
如何在Java中将字符串3.0103E-7转换为0.00000030103?(How to convert a string 3.0103E-7 to 0.00000030103 in Java?)

如何在Java中将字符串0E-11转换为0.00000000000? 我想以非科学记数法显示数字。 我已经尝试过查看Java中的数字格式化程序,但是我需要具体说明我想要的确切小数位数,但我不会总是知道。 我只想要原始数字所指定的小数位数。

How to convert a string 0E-11 to 0.00000000000 in Java? I want to display the number in non scientific notations. I've tried looking at the number formatter in Java, however I need to specific the exact number of decimals I want but I will not always know. I simply want the number of decimal places as specificed by my original number.

最满意答案

我会使用BigDecimal.Pass将您的字符串作为参数添加到其中,然后使用String.format来表示新创建的BigDecimal而不使用科学记数法。 也可以使用Float或Double类。

I would use BigDecimal.Pass your string into it as a parameter and then use String.format to represent your newly created BigDecimal without scientific notation. Float or Double classes can be used too.

更多推荐

本文发布于:2023-08-01 12:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1358055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   中将   如何在   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!