I won't talk about it, just like the original concept of rounding.
Taking an even number from five means that if the number to be discarded is five, it depends on whether the previous number is even or odd. Even numbers are discarded and odd numbers are input. For example, 4.5, 4 is even, 5.5, 5 is odd, input.
The advantage of this is that the probability of carrying at 5 o'clock is 50%, which is more scientific.
I often see the problem of circular function in my knowledge. Many people think that this function is a rounding algorithm, but it is actually wrong.
In VB, VBScript, C #, J # and T-SQL, the Round function adopts bankers' rounding algorithm, that is, four houses, six houses and five houses. In fact, this is also the rounding standard stipulated by IEEE. Therefore, all languages conforming to IEEE standards should adopt this algorithm.
Although "rounding" is the earliest algorithm in China, which deserves our pride, we can't think that it is always advanced. After all, it has a history of nearly 2000 years (about 1700 years ago, astronomer Yang Wei explicitly put forward the "rounding method").
Rounding algorithm carries round every Friday, which leads to the problem of too large results, especially in a large number of data statistics. For example:
source
Round up or down
Banker rounding
1. 1249
1. 12
1. 12
1. 1248
1. 12
1. 12
1. 1252
1. 13
1. 12
1. 1250
1. 13
1. 12
1. 1354
1. 14
1. 14
1. 135 1
1. 14
1. 14
1. 1352
1. 14
1. 14
1. 1353
1. 14
1. 14
1. 136 1
1. 14
1. 14
1. 1360
1. 14
1. 14
1. 13 13
1. 1340
1. 1320
The average value of this set of raw data is1.1313; If two decimal places are rounded off, their average value is 1. 134, and the error is+0.0027; If the banker is used for rounding, the result is 1. 1320 and the error is +0.0007. It can be seen that the rounding error is much larger. In financial calculation and statistics, accuracy is very important, which is also the origin of the name of banker rounding. Bankers don't like rounding.
Rounding is the content of my math class in primary school. Most people in China firmly believe that this algorithm should be used when rounding decimal places. Fortunately, it is said that the current primary school mathematics curriculum has officially written the banker rounding into the textbook. Children in the future probably won't have the problems they have now.
For information about rounding functions and banker rounding in programming, please refer to Microsoft's knowledge base:
Q194983prb: The rounding function in VBA 6 and Excel spreadsheets is different.
Q 196652 How to: Implement a Custom Rounding Process