How to avoid floating point errors?
I was trying to write a function to approximate square roots (I know there’s the math module…I want to do it myself), and I was getting screwed over by the floating point arithmetic. How can you avoid that? def sqrt(num): root = 0.0 while root * root < num: root += 0.01 return root Using … Read more