Answer the question
In order to leave comments, you need to log in
Rounding of intraservice cash amounts
Let me ask you a question with an example.
There is a web service in which there are two parties of participants. One party pays the other daily N rubles in intraservice currency equivalent to the Russian ruble. The unit of the ruble, in life, has values up to 0.1 rubles (i.e. one penny).
The system, on the other hand, provides for payments as a percentage of a specific amount (a referral system of payments from the income of a participant attracted to the system) and this amount, due to a percentage of another amount, often has a value of 1.333333 ... rubles.
Question: how is it more correct to round the digital values of cash in the system, or to what order should they be recorded and rounded?
Answer the question
In order to leave comments, you need to log in
You can use banking rounding.
This rounding method is a somewhat "modernized" version of mathematical rounding. All numbers in which the "discarded" digit is not equal to 5 are rounded according to the rules of the mathematical method. And others according to the following rule:
- if the figure that comes before the number 5 is even, then rounding is carried out down;
- if the figure that comes before the number 5 is odd, then rounding up is carried out.
As Wikipedia notes, using this method "disappears systematic rounding error when summing a large number of numbers."
It depends. For example, in the case of 1.3333(3) - what does the participant want to receive - 1.34 or 1.33?
In the case of a certain distribution, for example, a percentage, you can store the base value and% (it is clear that the base value will be normalized because it is money) and round up to an arbitrary sign when calculating. When a payment is made, a certain amount is actually paid and it is also already normalized (because it is real money), so there is no problem with rounding here either.
Until what sign to store? Depends on the currency, two decimal places are enough for the ruble (but normalized!!!)
I once worked with banking software, where the numbers were stored in the 18.5 format, if memory serves (or 21.9, I don’t remember exactly). This made it possible not to lose even 1 kopeck when calculating the amounts of money that were formed by several hundred transactions. When issuing funds, the amount for issuing was rounded down, but the undisbursed amount of 0.00XXX always remained on the account
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question