Data calculation exception for double and decimal

Source: Internet
Author: User

Scenario:

When the customer prompts that the stock is insufficient, the customer can check the stock quantity with the naked eye.

However, scheduling tracking finds "Incredible" exceptions.

Simple analysis:

1. It's okay to convert to decimal for calculation. Data is not lost because of its high precision and different storage methods.

2. Data loss in double mode. The highest accuracy. Data overflow occurs after binary conversion, resulting in data loss.

3. The default value of C # is double, which indicates data loss.

Summary:

After reading several posts, C # introduces the decimal type to support finance and currency computing. Therefore, decimal is used directly in the future when processing financial and other data.

 

Reference:

Http://bbs.csdn.net/topics/70318335

Http://www.cnblogs.com/jhxk/articles/1605755.html

Http://www.cnblogs.com/haiyang1985/archive/2009/03/03/1402394.html

Http://blog.csdn.net/lai123wei/article/details/7220276 read this post to understand the cause of my problem.

 

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.