Conversion from exponential form to decimal in Java

前端 未结 9 1051
夕颜
夕颜 2020-12-09 06:50

I want to convert exponential to decimal. e.g. 1.234E3 to 1234.

相关标签:
9条回答
  • 2020-12-09 07:33

    try the following

    long l;
    double d;  //It holds the double value.such as 1.234E3 
    l=Double.valueOf(time_d).longValue();
    

    you get the decimal value in the variable l.

    0 讨论(0)
  • 2020-12-09 07:40

    You can do:

    BigDecimal
        .valueOf(value)
        .setScale(decimalLimit, RoundingMode.HALF_UP)
        .toPlainString()
    
    0 讨论(0)
  • 2020-12-09 07:43

    How about BigDecimal.valueOf(doubleToFormat).toPlainString()

    0 讨论(0)
提交回复
热议问题