5th Nov 2018, 5:40 PM
Orsrozsondai
Orsrozsondai - avatar
2 odpowiedzi
+ 6
This happens because accurate division (and operation and representations) with floating is expensive. So it's implemented an approximative algorithm (with less precision) for get more speed. If you want to be precise. Python 3 you can use decimal library. JS probably have a equivalent library too. Edit: Here a example: https://code.sololearn.com/cMkFYAJHmcyY/?ref=app Edit1: Remember round is not good solution. the imprecision can make round miss sometimes.
5th Nov 2018, 5:58 PM
Anya
Anya - avatar
+ 4
Floating point arithmatic is not 100% accurate all the time due to multiple reasons stated here: https://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples
5th Nov 2018, 5:50 PM
TurtleShell
TurtleShell - avatar