Why does the financial system keep only two decimal places? What if there are more than two decimal places?

  java, question

I suddenly found a problem. The financial system in our life has at most two decimal places, such as 12.37, which is accurate to the minute. However, when two decimal places and non-integer numbers are calculated, three decimal places are also obtained. For example, the daily rate of the bank, there will definitely be three decimal places or more. But why can we only see the balance of two decimal places? Isn’t the extra decimal place also money, omitted, and how omitted? I feel this question is a little interesting.

My guess is:

In fact, as long as our financial system only uses two decimals, when more than two decimals are generated, the following decimals will not be used, directly, instead of full five-in-one. if one is entered, it will result in more money to users, even if it is 0.001 yuan, which is also a huge loss in the whole system. therefore, when more than two decimals are generated, the following decimals can only be directly omitted, even if it is 0.239, it will be 0.009 yuan, and the loss of 0.009 yuan can only be borne by users.

For example, the bank’s system, Alipay, these are two decimal places, we generally use the balance fielddecimal(10,2), keep two decimal places, I suddenly thought of this problem, very tangled, don’t know whether I think so.

For example, Alipay uses points and vouchers to offset multiple orders at the same time, the deducted money seems to be split under each order according to the proportion of the amount of the order, so there is a decimal number, but the decimal number is also two. I haven’t paid attention to it carefully, and I don’t know if the deduction of multiple orders is equal to the amount deducted when placing the order.

If it is what I think, then I feel that we must have lost a lot of money a lot of times? I originally wanted to keep a few more decimal places to solve this problem, but I felt that there might be an infinite number of decimal places, which is still unlikely. Can users only lose money, even a little?

I hope the great god can give me some advice and make me confused. at present, this kind of problem is being encountered in the project.

Thank you!

This piece of money problem still needs to consider the business needs. According to my previous practice, it is to save 4 decimal places. According to different scenarios, choose! However, all amounts displayed at the front desk are only 2 digits, andAccess down

Such as the following scenario:

Balance withdrawal, transfer-out, etc


General meetingAccess downFor example10.1234; The actual amount that can be withdrawn is10.12.

Staging correlation


For example, the total amount of bank credit is 1000 yuan, and then I just bought one thing and spent all of it. It is in stages of operation. It is divided into three phases.
According to normal thinking is1000/3=333.3333333; After rounding, it becomes333.33; When you have finished the third installment, you will find that only one has been returned.999.99. This is the pit

The general practice is:
The first two periods shall be rounded off. In the last phase, calculate by subtraction:1000-333.33-333.33=333.34;

Other instructions

According to different businesses, the number of reserved digits and the choice are different. Such as the net value of the fund. The length of the decimal point still affects the amount of money. The more accurate this piece is, the better. Communicate specific requirements with the product!