Why subtraction in float in so large? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 4

Why subtraction in float in so large?

I tried subtracting 8.5 from 8.6 , and the answer was different in 2.x and 3.x versions of Python. In 3.x the answer came over 0.999999999999864 While in 2.x it was simply 0.1. Why??

26th Mar 2019, 5:49 PM
Anmol Sudhendu
Anmol Sudhendu - avatar
1 Antwort
+ 10
Py3 has some limitations with float operations while py2 hadn't. Try referring to this link for description and a solution as well. https://stackoverflow.com/questions/36541776/floating-point-subtraction-in-JUMP_LINK__&&__python__&&__JUMP_LINK
31st Mar 2019, 11:16 PM
Arushi Singhania
Arushi Singhania - avatar