Converting exponential value in java to a number format

前端 未结 12 1465
旧巷少年郎
旧巷少年郎 2020-12-06 05:47

I am trying to read the values from excel sheet using java. When i type more than 10 letters in a cell in excel it is displaying in exponential form like \"9.78313E+2\". but

12条回答
  •  攒了一身酷
    2020-12-06 06:12

    You can use BigDecimal, if you want the exact value that you have in Excel Sheet: -

    BigDecimal bd = new BigDecimal("4256411411");
    System.out.println(bd.doubleValue());
    
    // If you are sure that's not a floating point number, then use
    System.out.println(bd.longValue());  
    

    Prints: -

    4.256411411E9  
    4256411411
    

提交回复
热议问题