I used python to round floating point numbers, and I am confused about how round numbers of computers are. For instance:
round(1.55, 1) = 1.6 # this is what I would expect; however
round(1.65, 1) = 1.6 #this is what confuses me. Is it supposed to be 1.7?
Another example:
round(1.85, 1) = 1.9
round(1.95, 1) = 1.9
I suppose this may have something to do with the conversion between binary and decimal. My question is, how can I find out if end 5 is omitted or not? Thank you so much for your help!
source
share