0
Error
if 0.1+0.2==0.3: print("True") else: print("False") #output: False #explain plz
2 odpowiedzi
+ 3
In most programming languages including Python, floating-point values are stored in the IEEE 754 format. This format represents numbers in binary. In binary, these floating-point numbers don't have an exact representation. Think of it as 10/3, the result is something like 3.3333... it doesn't have an exact representation.
For instance, 0.1 in binary isn't actually just 0.100000.. it's 0.000110011... and it's the same case with 0.2. So when you add the values together, the result is something like 0.3000004, which is not equal to exactly 0.3.
+ 3
Following Afnan Irtesum Chowdhury answer here is how to make the answer
True
https://sololearn.com/compiler-playground/cpkRcI8FR0ra/?ref=app