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.
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
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.