When adding 0.2 to 0.1 in python why is the sum 0.30000000000000004? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

When adding 0.2 to 0.1 in python why is the sum 0.30000000000000004?

16th Jan 2022, 2:56 AM
Pawan
2 Réponses
+ 3
Computers use binary numbers so do python. Some decimal numbers cannot be expressed exact in binary (infinite binary number) so computer do an aproximation.
16th Jan 2022, 3:16 AM
Christina Ricci
Christina Ricci - avatar