草庐IT

roundPrecision

全部标签

java - ASP .net C# Decimal 与 Java Double 之间的舍入不匹配

我正在将.NET代码转换为Java,遇到了精度不匹配的问题。.NET代码:privatedecimalroundToPrecision(decimalnumber,decimalroundPrecision){if(roundPrecision==0)returnnumber;decimalnumberDecimalMultiplier=Math.Round(number/roundPrecision,MidpointRounding.AwayFromZero);returnnumberDecimalMultiplier*roundPrecision;}在上面的代码中调用roundTo