A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
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.
anonymous
 one year ago
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.

This Question is Open

e.mccormick
 one year ago
Best ResponseYou've already chosen the best response.0Rounding 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.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.