Math. Round (double, INT) Evaluate uses the four homes, six homes, five exams

Source: Internet
Author: User
Msdn does not provide a detailed description. An example is provided;
 
Math. Round (3.44, 1); // returns 3.4.math.round (3.45, 1); // returns 3.4.math.round (3.46, 1); // returns 3.5.

According to his example, the result is "five homes and six inputs". I changed the number and the result will be completely changed.

Math. Round (3.445, 1); // returns 3.4.
Math. Round (3.455, 1); // returns 3.5.
Math. Round (3.465, 1); // returns 3.5.

Math. Round (3.450, 1); // returns 3.4. (adding 0 is invalid)

Math. Round (3.4452, 2); // returns 3.45.
Math. Round (3.4552, 2); // returns 3.46.
Math. Round (3.4652, 2); // returns 3.47.

A:
Many countries in the world have widely adopted the "four homes and six access method ". The National Science and Technology Commission of China made a recommendation in 1955. The "four homes, six homes, and six homes" can be summarized as follows: "four homes, six homes, six homes, five homes, six homes, and five homes, six homes, five homes, six homes, six homes, five homes, six homes, five homes, before five, it is odd to enter one."
A:
In the field of engineering, finance, and science, we often think that it is more accurate to round a decimal point to the nearest even number (rather than always round it up, that is, the "four homes and six inputs" method we call here.
Math. Round () method used by bankerAlgorithmIs based on the IEEE Standard 754 international standard.

it is said that all European banks adopt this model.
I don't know about this. Round handles this in five-to-five pairs.
I also encountered this problem. It was also strange at first, and later I Came To See help. It was really a couple of four homes, six homes, five meals, although the four homes and six entrances mentioned above are international standards, many business systems in China still adopt a rounding approach. No way, I have to write a method to rounding them. However, there is a good method on the Internet. Although it may be tricky, there is usually no problem, that is, add 0.0000000001 to the back, a small number, and then take two more, three or four digits are okay. Try it

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.