我正在使用 Double 通过 Internet 将纬度和经度发送到服务器,但值是:
2.1188253687859282E155
有什么办法可以使这个 let 精确吗?我真的只需要“。”之后的前六个数字。 比如
2.118825
有什么办法吗?如果是这样怎么办?
非常感谢
最佳答案
您需要使用 DecimalFormat
DecimalFormat formatter= new DecimalFormat("00.000000");//Your precision specified in the number of zeroes.
formatter.setRoundingMode(RoundingMode.UP);//In Case you need rounding
String s=formatter.format(double_val).toString();
关于java - Android Double 过于精确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28305086/