zoukankan      html  css  js  c++  java
  • 科学技术法转成BigDemcial

    目的:将类似“-412615050624334534247E-3”转成“-412615050624334534.247”

    工具:用到BigDemcial

    Code:

        public static void main(String[] args) {
    //        String str = "+0.000615050624334534247e-3";
            String str = "-47E-7";
    //        DecimalFormat df=new DecimalFormat();
    //        df.setParseBigDecimal(true);
            try {
    //            Number number = df.parse(str);
    //            BigDecimal decimal = (BigDecimal)number;
                BigDecimal decimal = new BigDecimal(str);
                System.out.println("********* " + decimal.toPlainString() );
            } catch (Exception e) {
                e.printStackTrace();
            }
    //        String result=df.format(dValue);
    //        System.out.println("---------" + result);
        }
    }
    

      起初以为会用到DecimalFormat包,但经过测试,一个BigDemcial就搞定!

    清醒时做事,糊涂时读书,大怒时睡觉,独处时思考; 做一个幸福的人,读书,旅行,努力工作,关心身体和心情,成为最好的自己 -- 共勉
  • 相关阅读:
    正则表达式之re模块
    collections模块
    openpyxl模块
    hashlib模块
    random模块
    os模块
    sys模块
    nodeType
    数据类型转换
    添加删除
  • 原文地址:https://www.cnblogs.com/hello-yz/p/4419123.html
Copyright © 2011-2022 走看看