0

Something very interesting

Do you know if you enter 0.2 + 0.1 in python output is 0.3000000000003? Or you enter 999999999.0 - 999999998.0 output is 2.0???

12th Apr 2020, 7:50 AM
Ali Khosroanjam
Ali Khosroanjam - avatar
3 Réponses
0
Python does not handle floats properly. That's why that result occurs. You could just round off to your desired results.
12th Apr 2020, 7:53 AM
Taranjeet
Taranjeet - avatar
0
Second is true.pleas copy these numbers 9999999999999999.0 - 9999999999999998.0
12th Apr 2020, 8:05 AM
Ali Khosroanjam
Ali Khosroanjam - avatar
- 1
The second one isn't right(at least in python3) . But the first one happens because float isn't exact value and it is approximate in python.
12th Apr 2020, 8:00 AM
ΛM!N
ΛM!N - avatar