Math. Round is used to round the value by the specified small number,Is not.When this type of rounding is performed, It is rounded up to the nearest or rounded up to five.
In fact, in VB, VBScript, C #, J #, the number of round functions in the T-SQL is the banker's rounding algorithm, that is, four homes, six homes, five homes, and five shopping carnivals. In fact, this is also the IEEE defined rounding standard. Therefore, all IEEE-compliant statements should use this algorithm.
If you want to rounding it up, remember to add the limit number.Midpointrounding. Awayfromzero
Decimal a_round = 0;
A_round = math. Round (convert. todecimal ("5.265"), 2); // The result is 5.26 (number of top expert rounding algorithms midpointrounding. toeven numbers)
A_round = math. Round (convert. todecimal ("5.266"), 2); // The result is 5.27 (number of top expert rounding algorithms midpointrounding. toeven numbers)
A_round = math. Round (convert. todecimal ("5.275"), 2); // The result is 5.28 (number of top expert rounding algorithms midpointrounding. toeven numbers)
A_round = math. Round (convert. todecimal ("5.265"), 2, midpointrounding. awayfromzero); // The result is 5.27 (rounding the algorithm)
A_round = math. Round (convert. todecimal ("5.265"), 2, midpointrounding. toeven); // The result is 5.26 (ranking expert rounding algorithm)
A_round = math. Round (convert. todecimal ("5.275"), 2, midpointrounding. awayfromzero); // The result is 5.28 (rounding the algorithm)
A_round = math. Round (convert. todecimal ("5.275"), 2, midpointrounding. toeven); // The result is 5.28 (ranking expert rounding algorithm)
HoweverSQL MSNot
The Round Function of ms SQL is rounded
Math. Round