In ps 4.4 (function testFindMaxExpenses) why is my answer 1229.95297872 and not 1229.95548986? Help greatly appreciated! http://dpaste.com/533442/
Hi, As far as I can tell the problem specifies that your answer should be *close* to 1229.95548986, so your numbers look ok. The reason *why* your answer is not the same stems from the fact that floating point representation of numbers (and that's what you get if you use decimal-dot notation in Python) cannot express any number with full precision. As a consequence small errors can accumulate over multiple operations and the final result can be different depending on the number of operations, their order, relative magnitude of numbers and so on. Numerical analysis deals with this kind of problems. That's why floating point numbers are not used for any serious calculations involving money.
Thanks for your response!
Hello, Changing the line in user mmapplebeck code: while test[-1] < 0 or test[-1] > epsilon: To this: while abs(test[-1]) > epsilon: Gave me exact answer as stated in ps4.py: 1229.95548986.
Join our real-time social learning platform and learn together with your friends!