On problem set #1 part 3, are there rules about when to use the round function? My code is a little different from the answer code. My answers for monthly payment match the answers, but my balance is a couple of cents off. Very annoying. Also, can anyone explain why this line of code is in the answer? # Round monthly payment up to the nearest cent monthly_payment = round(monthly_payment + 0.004999, 2) I don't know why they have to recalculate the balance after they do this. Any help would be appreciated. Thanks.
Rounding errors in floating point numbers are a common issue. Which whey they go is to some extent machine dependent. This has to do with memory structures and how decimals, as opposed to whole numbers, get converted to and from binary.
Join our real-time social learning platform and learn together with your friends!