-1
Galera wrote a program where I decrease a variable in 0.01 and from the third decrease, python simply recognizes the value 0.01 as 0.009999999999988617 and ends up giving problems in my code. In the example code below, run as you are and then change the value from a to 0.03 or more, and see what I say. Why is this? a = 0.02 while a != 0.00: a -=0.01 print(a)
The type of float data is inherently inaccurate. If you need accuracy use other type of data. Search by Decimal class.
– anonimo
@anonimo Decimal exists in Python ?
– JeanExtreme002
@Jeanextreme002 decimal - Decimal and floating point fixed-point arithmetic
– Augusto Vasques