I am trying to add a two float values(6.66,12.208) in python3 but it return 19.868000000000002. is it right? can someone please tell me the reason
Asked
Active
Viewed 597 times
-1
-
Does this answer your question? [Why does the floating-point value of 4\*0.1 look nice in Python 3 but 3\*0.1 doesn't?](https://stackoverflow.com/questions/39618943/why-does-the-floating-point-value-of-40-1-look-nice-in-python-3-but-30-1-doesn) – Sujit Dec 29 '20 at 09:06
-
Does this answer your question? [Is floating point math broken?](https://stackoverflow.com/questions/588004/is-floating-point-math-broken) – phuclv Dec 29 '20 at 09:16
-
yes... i am facing the same problem. but i didn't get a solution.can you please explain and apply for this example? @Sujit – sivaganesh Murugesan Dec 29 '20 at 12:27
-
@sivaganeshMurugesan there is no solution, it's like an approximation. I doubt you will need numbers that accurate, just round off to the second or third decimal and display your answer. Do you want me to write an answer to display the sum up to the third decimal? – Sujit Dec 29 '20 at 12:37
-
ohhhh... okay.. Great..! Iam going to try this way. i will let you know if i cant. – sivaganesh Murugesan Dec 29 '20 at 12:43