Why is 0.1 + 0.2 -0.3 not equal to​ zero? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

Why is 0.1 + 0.2 -0.3 not equal to​ zero?

27th Jun 2017, 10:16 AM
Parth
Parth - avatar
3 Réponses
+ 6
https://docs.python.org/2/tutorial/floatingpoint.html
27th Jun 2017, 10:28 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
It's because these numbers will convert to binary then computer can read them and use them so there will be a little difference as 0.2 will be 0.2000000001 but there's another method which helps for comparing numbers that can solve this
27th Jun 2017, 10:39 AM
Hetbo.net
Hetbo.net - avatar
0
This reeally depents on your language. In many language floats are unstable. If you want a full readup: https://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate
27th Jun 2017, 10:50 AM
Harm Zeinstra
Harm Zeinstra - avatar