Convert scientific notation to decimal notation

后端 未结 3 1846
情歌与酒
情歌与酒 2021-01-21 02:10

There is a similar question on SO which suggests using NumberFormat which is what I have done.

I am using the parse() method of NumberFormat.

public sta         


        
3条回答
  •  一整个雨季
    2021-01-21 02:57

    When you use DecimalFormat with an expression in scientific notation, you need to specify a pattern. Try something like

    DecimalFormat dform = new DecimalFormat("0.###E0");
    

    See the javadocs for DecimalFormat -- there's a section marked "Scientific Notation".

提交回复
热议问题