False rounding in PYTHON3: round ()
Creation time: |
2017/12/5 17:08 |
|
Cn_simo |
Label: |
Python basics, round, rounding |
first, this is not a bug!
when using round (), it is found thatcan be found that there are some numbers that are not really rounded!
This is very confusing, check the data found that in the Python2 this is still normal.
- The definition of round () in Python2 is: a multiple of the negative ndigits in 10 takes the nearest number of numbers back, if it is stored in two times count as close as number, then take away from 0
- The definition of round () in Python3 is: A multiple of the negative ndigits in 10 takes the nearest number of numbers to return, and if there are two multiples as close as #, take even
round () in the Official document: "Reference link"This is not a bug! I still can't figure out why round is going to do this, but there's no doubt it's a pit!second, Accurate rounding method Summary:"reference link"
Method 1: Law 2: Also in Python3 '/' is the ordinary division, divisible by '//'
False rounding in PYTHON3: round ()