Math. Round

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.