+ 1
Why 4.300000000001
i = 1.0 while i <= 12.0: print(i) i = i + 1.1
3 Réponses
+ 4
everything in the machine is stored in binary system for example
x=5
will be 101
but some decimal numbers cannot be converted to binary system so it rounds it to the closest number
+ 4
Because floating-point numbers are inaccurate and certain numbers can't be represented accurately.
See the following two resources for info:
https://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate
https://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm
+ 3
When you use double and you add this multiple times it also has a little more than what you gave then it doesn't add 1.1 but 1.1000000000000001(just example)