我发现谷歌搜索的所有内容都表明,以下任何一种方法都会将双倍减少到两位小数.
double roundToFourDecimals(double d)
{
DecimalFormat twoDForm = new DecimalFormat("#.##");
double myD = Double.valueOf(twoDForm.format(d));
return myD;
}
double nextLon = (double)Math.round(bnextLon * 100.0) / 100.0;
Run Code Online (Sandbox Code Playgroud)
但这对我都不起作用.double的值是3.3743984E7,结果是相同的.怎么了?