Why is it always impossible to get the correct value after rounding in the round?

Source: Internet
Author: User

Why is it always impossible to get the correct value after rounding in the round?

Author: cg1 excerpt: access911.net
Problem:

Why is it always impossible to get the correct value after rounding in the round?
For example
Round (11.115, 2) is equal to 1.11 instead of 1.12.

For example, I wrote the following statement in the access query:
Select round (0.005, 2) as ID;
The result is not the expected 0.01, but 0. What should I do if I want to get 0.01?

 

Answer:

& Lt; table width = "100%" & gt;
The reason is very simple. During exact calculation, you should use the "currency" field instead of the commonly used "Number" and "Double Precision ", the double-precision storage method should not be directly stored in decimal format, but calculated by scientific notation, which will always produce errors.
If you must use dual precision, we recommend that you store the decimal places and integer digits separately.

you can use the following statement to solve the problem in a query

select format (0.005 ,'#. # ') as ID;

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.