在Java中,有没有办法把科学记数法转换成固定的记数法?目前我得到的代码如下:
DecimalFormat dfmt=new DecimalFormat("######:#######");
print(dfmt.format((new BigDecimal((Math.pow(10,-3)*3000),MathContext.Decimal64)).stripTrailingZero()));上面的代码确实将科学记数法转换为固定记数法,但是如果结果大于零,小数位将被忽略。在上面的示例中,它打印3;而不是3.0
发布于 2012-05-21 21:53:15
使用the pattern 0.0
BigDecimal d = new BigDecimal("12345678901234567890"); // large integer
System.out.println(new DecimalFormat("0.0").format(d));输出(在我的语言环境中):
12345678901234567890.0https://stackoverflow.com/questions/10686493
复制相似问题