About C # Math,
In other words, the last time the System Maintenance System Used JS to read the experiment data imported into Excel, it was automatically rounded down. Then I came to the customer's site to hear the customer's feedback about the Excel experiment data requirements.
On the basis of the statistical analysis, the concept of "odd-in-even-out" is more scientific than that of "Rounding-in". In a large number of computations, it makes the mean of the result error after rounding tend to zero, instead of entering the result every five as rounding, leading to a large number of results, which leads to accumulation of errors and system errors, "odd-in-even-house" minimizes the impact of rounding errors on the measurement results.
Math finds out, uses the Round overload, and uses MidpointRounding. ToEven to achieve odd-in-even.
// 4 double d = 5.214; double res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); // 5.21 // 6 d = 5.216; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); // 5.22/5 d = 5.215; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); /// 5.22 d = 5.225; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); // 5.22 // more than 3 digits after the decimal point, d = 0.7865666; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); /// 0.79 d = 0.786; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); /// 0.79 d = 0.785; res = Math. round (d, 2, MidpointRounding. toEven); Console. writeLine (res); // 0.78.